SQLµ÷ÓÅ
SQL Server ²éѯ
²éѯµÄʱºòÓ¦¸Ã¾¡Á¿°´ÕÕ¸´ºÏË÷ÒýÖеÄ˳ÐòÀ´×öÌõ¼þ²éѯ£»£¨±ÈÈçIXCÖÐspInterActiveInstance_GetByIDToStatÌõ¼þand ProcessState<>99µÄλÖã©£»
Èç¹ûÔÚ³ÌÐòÖÐÓÐFor»òÕßÊÇForeach£¬ÔÚ´æ´¢¹ý³ÌÖÐÓÖÓÐIF Exists£¬ÄǾÍÒª¿´ÊÇ·ñ¿ÉÒÔÔÚ±íÖмÓÈ븴ºÏË÷ÒýÁË£¬IF Not Exists¿ÉÒÔת»»ÎªIF ExistsÀ´Ê¹ÓÃË÷Òý£»
ÔÚ²éѯÖо¡Á¿ÉÙʹÓÃ*»òÕßÈ«±í×Ö¶ÎÀ´²éѯÊý¾Ý¡£µÚÒ»£¬·µ»ØµÄÊý¾Ý¼¯±È½Ï´ó£»µÚ¶þ£¬²úÉú¸ü¶àµÄIO²Ù×÷£»µÚÈý£¬»áʹÓõ½Bookmark lookupµÄ²éѯ¼Æ»®£¬ÐÔÄÜÓÐËùϽµ£»Èç¹ûÄÜʹÓõ½¸²¸ÇË÷ÒýÀ´²éѯÊÇ×îÀíÏëµÄ£»
ÏÂÃæ¹ØÓÚ²éѯµÄÐÔÄܱȽÏ
·µ»ØÐÐÊý½Ï¶à£ºË÷Òý¸²¸Ç>¾Û¼¯Ë÷Òý>±íɨÃè>¶Ñ¼¯µÄ·Ç¾Û¼¯Ë÷Òý>¾Û¼¯µÄ·Ç¾Û¼¯Ë÷Òý
·µ»ØÐÐÊý½ÏÉÙ£ºË÷Òý¸²¸Ç=¾Û¼¯Ë÷Òý>¶Ñ¼¯µÄ·Ç¾Û¼¯Ë÷Òý>¾Û¼¯µÄ·Ç¾Û¼¯Ë÷Òý>±íɨÃè
±È½ÏÄÑÀí½âµÄ¿ÉÄÜÊÇ£º¶Ñ¼¯µÄ·Ç¾Û¼¯Ë÷Òý>¾Û¼¯µÄ·Ç¾Û¼¯Ë÷Òý¡£ÏÂÃæÊǸöÈ˼û½â£¬¶Ñ±í¾ÍÊÇûÓоۼ¯Ë÷ÒýµÄ±í£¬ÊµÖÊÉϾÍÊÇÔÚÒ»¸öûÓоۼ¯Ë÷ÒýµÄ±íÖмÓÈë·Ç¾Û¼¯Ë÷ÒýºÍÒ»¸öÔÚ¾Û¼¯±íÖмÓÈëͬһ×ֶεķǾۼ¯Ë÷Òý£»£¨¾Û¼¯£©·Ç¾Û¼¯Ë÷Òý-¶¨Î»Æ÷-¾Û¼¯Ë÷Òý-Bookmark lookup-·µ»ØÖ¸¶¨×Ö¶ÎÖµ£»£¨¶Ñ¼¯£©·Ç¾Û¼¯Ë÷Òý-¶¨Î»Æ÷-¶ÔÓ¦µÄÊý¾ÝÐеÄÖ¸Õë-·µ»ØÖ¸¶¨×Ö¶ÎÖµ£»
²»ÒªÔÚWhere×Ö¾äÖеÄÁÐÃû¼Óº¯Êý£»Èç¹ûÓжÔÁÐÖµ½øÐÐÅжϵģ¬¾¡Á¿°Ñ²Ù×÷·û£¨±ÈÈç+¡¢-¡¢*µÈ£©·Åµ½=ºÅµÄÓұߣ»
Ë÷Òý By Viajar
¸´ºÏË÷Òý£¨where A And B£©Èç¹ûûÓжÔAºÍB×öµ¥Ò»Ë÷Òý£¬²éѯµÄʱ¼äΪa£»Èç¹û¶ÔA×öµ¥Ò»Ë÷Òý£¬²éѯʱ¼äΪb£»Èç¹û¶ÔB×öµ¥Ò»Ë÷Òý£¬²éѯʱ¼äΪc£»Èç¹û¶ÔA¡¢B×ö¸´ºÏË÷Òý£¬²éѯµÄʱ¼äΪd£¬ÄÇʱ¼äµÄ±È½Ï¾ÍÓ¦¸ÃÊÇa>b=c>d£»£¨±ÈÈçspMsgReader_DistributeÖÐʹÓÃWHERE InfoID=@infoID AND UserID=@userID£¬²åÈë7000´ÎµÄʱºò¾ÍºÜÃ÷ÏԵؿ´µ½ÐÔÄÜÁË£»£¨8Ãë±È1£º50Ã룩עÒâÉýÐòºÍ½µÐòµÄÇø±ð£¿
µ±¸ßÑ¡ÔñÐԵķǾۼ¯Ë÷Òý´ïµ½5%µÄÑ¡ÔñÐÔʱ£¬¸ÃË÷ÒýÊǷdz£ÓÐÓõģ»
¹ØÓÚ¸´ºÏË÷ÒýµÄÊôÐÔÁÐλÖÃÎÊÌ⣬Ӧ¸Ã°Ñ¸ßÑ¡ÔñÐÔµÄÁзŵ½×î×ó±ß£¨ÒÑÇ°¾ÍºöÂÔÁËÕâ¸ö¸ßÑ¡ÔñÐÔµÄλÖã©£¬ÄǸöͨ¹ýIPºÍUrlIDµÄSARGÖÐÎÒÃÇ¿ÉÒÔ´´½¨Ò»¸öIPºÍUrlIDµÄ¸´ºÏË÷Òý£¬Í¨¹ýÒµÎñÀ´Ëµ£¬ÎÒÃDzâÊÔµÄʱºò¿ÉÄÜÊÇIPµÄÖظ´Á¿±È½Ï´ó£¬µ«ÊÇÔÚÉú³É»·¾³ÖУ¬Ó¦¸ÃÊÇUrlIDµÄÖظ´Á¿»á±È½Ï´ó£¬ËùÒÔ¾ÍIP·Åµ½¸´ºÏË÷ÒýµÄ×î×ó±ß£»
¶ÔEasyURLÌøת¹¦ÄÜÖУ¬ÐèҪͨ¹ýÊäÈëµØÖ·À´²éѯĿ±êµØÖ·£¬Õâ¸öÊý¾Ý¿â²éѯ¿ÉÒÔʹÓø²¸ÇË÷Òý£¬²éѯµÄËÙ¶ÈÊÇ×î¿ìµÄ£»
µ±·µ»ØÒ»¸ö¾Û¼¯Ë÷ÒýÁкÍÒ»¸ö·Ç¾Û¼¯Ë÷ÒýÁУ¬²¢ÇÒÊÇʹÓ÷
Ïà¹ØÎĵµ£º
ÔÚijЩÇé¿öÏ£¬ÎÒÃÇ»áÐèÒªÖ±½ÓÓÉÊý¾Ý¿âÖÐÈ¥³ýһЩ×ÊÁÏ¡£Õâ¿ÉÒÔ½åÓÉ DELETE from Ö¸ÁîÀ´´ï³É¡£ËüµÄÓï·¨ÊÇ£º
DELETE from "±í¸ñÃû"
WHERE {Ìõ¼þ}
ÒÔÏÂÎÒÃÇÓøöʵÀý˵Ã÷¡£¼ÙÉèÎÒÃÇÓÐÒÔÏÂÕâ¸ö±í¸ñ£º
Store_Information ±í¸ñ
store_name
Sales
Date
Los Angeles
$1500
Jan-05-1999
San Diego
$250
Jan-0 ......
ÔÚÕâÒ»Ò³ÖУ¬ÎÒÃÇÁгöËùÓÐÔÚÕâ¸öÍøÕ¾ÓÐÁгö SQL Ö¸ÁîµÄÓï·¨¡£ÈôÒª¸üÏ꾡µÄ˵Ã÷£¬ÇëµãÑ¡Ö¸ÁîÃû³Æ¡£
ÕâÒ»Ò³µÄÄ¿µÄÊÇÌṩһ¸ö¼ò½àµÄ SQL Óï·¨×öΪ¶ÁÕ߲ο¼Ö®Óá£ÎÒÃǽ¨ÒéÄúÏÖÔھͰ´ Control-D ½«±¾Ò³¼ÓÈëÄúµÄ¡ºÎÒµÄ×î°®¡»¡£
Select
SELECT "À¸Î»" from "±í¸ñÃû"
Distinct
SELECT DISTINCT "À¸Î»"
from "±í¸ñÃû"
......
×î½üÕýÔÚѧϰÓÃSQL×öһЩ¶«Î÷£¬ÔÚÒ»¸öÌû×ÓÉÏÃæ¿´µ½Õâƪ¶ÔºÜÓаïÖú£¬¾ÍתÔص½ÁË×Ô¼ºµÄBlogÀϣÍû¶Ô´ó¼ÒÒ²ÓаïÖú¡£
SQL²Ù×÷È«¼¯
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù× ......
À´Ô´:SQL°ïÖúÎĵµ
CASE
¼ÆËãÌõ¼þÁÐ±í²¢·µ»Ø¶à¸ö¿ÉÄܽá¹û±í´ïʽ֮һ¡£
CASE ¾ßÓÐÁ½ÖÖ¸ñʽ£º
¼òµ¥ CASE º¯Êý½«Ä³¸ö±í´ïʽÓëÒ»×é¼òµ¥±í´ïʽ½øÐбȽÏÒÔÈ·¶¨½á¹û¡£
CASE ËÑË÷º¯Êý¼ÆËãÒ»×é²¼¶û±í´ïʽÒÔÈ·¶¨½á¹û¡£
Á½ÖÖ¸ñʽ¶¼Ö§³Ö¿ÉÑ¡µÄ ELSE ²ÎÊý¡£
Óï·¨
¼òµ¥ CASE º¯Êý£º
CASE input_expression
&n ......
1.·ÖÎöϵͳÈÕÖ¾£¬Ò»ÐÐÒ»Ðп´×ÅʵÔÚÀÛÈË£¬ºÜ¶àÎÞ¹ØÈÕÖ¾£¬ÄܹýÂËϾͺÃÁË¡£Îı¾¹¤¾ß¹¦ÄÜʵÔÚÓÐÏÞ£¬ÓÚÊǺõ£¬½«windowsϵͳÈÕÖ¾µ¼Èësql serverÖУ¬Ö±½ÓsqlÖ®……¡£ÊµÑéÁ˼¸°Ñ£¬×îºÃµÄÊÇ£¬Ö±½Ó½«ÏµÍ³ÈÕÖ¾µ¼³öΪÎı¾µÄ£¬Ö±½Ótab·Ö¸îµÄ£¬µ¼ÈësqlµÄʱºò£º
н¨Êý¾Ý¿â->µ¼ÈëÊý¾Ý->ÏÂÒ»²½->Êý¾ÝÔ´Ñ¡ÔñÎı¾Îļþ- ......