SQL BETWEENµÄÓ÷¨
IN Õâ¸öÖ¸Áî¿ÉÒÔÈÃÎÒÃÇÒÀÕÕÒ»»òÊý¸ö²»Á¬Ðø (discrete) µÄÖµµÄÏÞÖÆÖ®ÄÚ×¥³öÊý¾Ý¿âÖеÄÖµ£¬¶ø BETWEEN ÔòÊÇÈÃÎÒÃÇ¿ÉÒÔÔËÓÃÒ»¸ö·¶Î§ (range) ÄÚ×¥³öÊý¾Ý¿âÖеÄÖµ¡£BETWEENÕâ¸ö×Ó¾äµÄÓï·¨ÈçÏ£º
SELECT "À¸Î»Ãû"
from " ±í¸ñÃû"
WHERE "À¸Î»Ãû" BETWEEN 'ÖµÒ»' AND 'Öµ¶þ'
Õ⽫ѡ³öÀ¸Î»Öµ°üº¬ÔÚÖµÒ»¼°Öµ¶þÖ®¼äµÄÿһ±Ê×ÊÁÏ¡£
¾ÙÀýÀ´Ëµ£¬ÈôÎÒÃÇÒªÓÉ Store_Information ±í¸ñÖÐÕÒ³öËùÓнéÓÚ January 6, 1999 ¼° January 10, 1999 ÖеÄ×ÊÁÏ£¬
Store_Information ±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-07-1999
San Francisco
$300
Jan-08-1999
Boston
$700
Jan-08-1999
ÎÒÃǾʹòÈ룬
SELECT *
from Store_Information
WHERE Date BETWEEN 'Jan-06-1999' AND 'Jan-10-1999'
Çë¶ÁÕß×¢Ò⣺ÔÚ²»Í¬µÄÊý¾Ý¿âÖУ¬ÈÕÆڵĴ¢´æ·¨¿ÉÄÜ»áÓÐËù²»Í¬¡£ÔÚÕâÀïÎÒÃÇÑ¡ÔñÁËÆäÖÐÒ»ÖÖ´¢´æ·¨¡£
½á¹û:
store_name
Sales
Date
San Diego
$250
Jan-07-1999
San Francisco
$300
Jan-08-1999
Boston
$700
Jan-08-1999
Ïà¹ØÎĵµ£º
×î½ü·ÖÇøMS SQL SERVERµÄ±í·ÖÇø£¬¸Ð¾õÉõÊǸ´ÔÓ¡£ 1. Ä¿Ç°Ö»ÖªµÀMS SQL SERVERÖ§³Ö·¶Î§·ÖÇøhttp://msdn.microsoft.com/zh-cn/library/ms187802.aspx£¬ ÔÚ¹Ù·½ÍøÕ¾µÄ˵Ã÷ÎĵµÀïÃ棬ҲûÓÐ˵֧³ÖÆäËûµÄ·ÖÇø¡£ÍøÉÏÓÐÐÖµÜ˵»¹Ö§³Öhash·ÖÇø¡£²»ÖªµÀÊÇÔõôʵÏֵġ£ÒòΪʹÓ÷ÖÇøº¯Êý£¬ÎÒÖ»ÖªµÀÄÜŪ³ö·¶Î§·ÖÇø¡£Í¬OracleµÄ±í·ÖÇøÏà± ......
ÔÚÊý¾Ý¿â¿ª·¢¹ý³ÌÖУ¬µ±Äã¼ìË÷µÄÊý¾ÝÖ»ÊÇÒ»Ìõ¼Ç¼ʱ£¬ÄãËù±àдµÄÊÂÎñÓï¾ä´úÂëÍùÍùʹÓÃSELECT INSERT Óï¾ä¡£µ«ÊÇÎÒÃdz£³£»áÓöµ½ÕâÑùÇé¿ö£¬¼´´Óijһ½á¹û¼¯ÖÐÖðÒ»µØ¶ÁÈ¡Ò»Ìõ¼Ç¼¡£ÄÇôÈçºÎ½â¾öÕâÖÖÎÊÌâÄØ£¿ÓαêΪÎÒÃÇÌṩÁËÒ»ÖÖ¼«ÎªÓÅÐãµÄ½â¾ö·½°¸¡£
1.1 ÓαêºÍÓαêµÄÓŵã
ÔÚÊý¾Ý¿ ......
SQLÓï¾äÓÅ»¯¼¼Êõ·ÖÎö
×î½ü¼¸ÖÜÒ»Ö±ÔÚ½øÐÐÊý¾Ý¿âÅàѵ£¬ÀÏʦ¾«Õ¿µÄ¼¼ÊõºÍÉú¶¯µÄ½²½âʹÎÒÊÜÒæ·Ëdz¡£ÎªÁËÈøü¶àµÄÐÂÊÖÊÜÒ棬ÎÒ³é¿Õ°ÑSQLÓï¾äÓÅ»¯²¿·Ö½øÐÐÁËÕûÀí£¬Ï£Íû´ó¼ÒÒ»Æð½ø²½¡£
Ò»¡¢²Ù×÷·ûÓÅ»¯
1¡¢IN ²Ù×÷·û
ÓÃINд³öÀ´µÄSQLµÄÓŵãÊDZȽÏÈÝÒ×д¼°ÇåÎúÒ׶®£¬Õâ±È½ÏÊʺÏÏÖ´úÈí¼þ¿ª·¢µÄ·ç¸ñ¡£µ«ÊÇÓÃINµÄSQLÐÔÄÜ×ÜÊÇ±È½Ï ......
SELECT Ö¸ÁîÈÃÎÒÃÇÄܹ»¶ÁÈ¡±í¸ñÖÐÒ»¸ö»òÊý¸öÀ¸Î»µÄËùÓÐ×ÊÁÏ¡£ Õ⽫°ÑËùÓеÄ×ÊÁ϶¼×¥³ö£¬ÎÞÂÛ×ÊÁÏÖµÓÐÎÞÖظ´¡£ÔÚ×ÊÁÏ´¦ÀíÖУ¬ÎÒÃǻᾳ£Åöµ½ÐèÒªÕÒ³ö±í¸ñÄڵIJ»Í¬ ×ÊÁÏÖµµÄÇé¿ö¡£»»¾ä»°Ëµ£¬ÎÒÃÇÐèÒªÖªµÀÕâ¸ö±í¸ñ/À¸Î»ÄÚÓÐÄÄЩ²»Í¬µÄÖµ£¬¶øÿ¸öÖµ³öÏֵĴÎÊý²¢²»ÖØÒª¡£ÕâÒªÈçºÎ´ï³ÉÄØ£¿ÔÚ SQL ÖУ¬ÕâÊǺÜÈÝÒ××öµ½µÄ¡£ÎÒÃÇÖ»ÒªÔ ......