SQLÓï¾äЧÂÊÎÊÌâµÄ¼¸µã×ܽá
1. SQLÓÅ»¯µÄÔÔòÊÇ£º
½«Ò»´Î²Ù×÷ÐèÒª¶ÁÈ¡µÄBLOCKÊý¼õµ½×îµÍ,¼´ÔÚ×î¶ÌµÄʱ¼ä´ïµ½×î´óµÄÊý¾ÝÍÌÍÂÁ¿¡£
µ÷Õû²»Á¼SQLͨ³£¿ÉÒÔ´ÓÒÔϼ¸µãÇÐÈ룺
¼ì²é²»Á¼µÄSQL£¬¿¼ÂÇÆäд·¨ÊÇ·ñ»¹ÓпÉÓÅ»¯ÄÚÈÝ
¼ì²é×Ó²éѯ ¿¼ÂÇSQL×Ó²éѯÊÇ·ñ¿ÉÒÔÓüòµ¥Á¬½ÓµÄ·½Ê½½øÐÐÖØÐÂÊéд
¼ì²éÓÅ»¯Ë÷ÒýµÄʹÓÃ
¿¼ÂÇÊý¾Ý¿âµÄÓÅ»¯Æ÷
2. ±ÜÃâ³öÏÖSELECT * from table Óï¾ä£¬ÒªÃ÷È·²é³öµÄ×ֶΡ£
3. ÔÚÒ»¸öSQLÓï¾äÖУ¬Èç¹ûÒ»¸öwhereÌõ¼þ¹ýÂ˵ÄÊý¾Ý¿â¼Ç¼Խ¶à£¬
¶¨Î»Ô½×¼È·£¬Ôò¸ÃwhereÌõ¼þÔ½Ó¦¸ÃÇ°ÒÆ¡£
4. ²éѯʱ¾¡¿ÉÄÜʹÓÃË÷Òý¸²¸Ç¡£¼´¶ÔSELECTµÄ×ֶν¨Á¢¸´ºÏË÷Òý£¬
ÕâÑù²éѯʱֻ½øÐÐË÷ÒýɨÃ裬²»¶ÁÈ¡Êý¾Ý¿é¡£
5. ÔÚÅжÏÓÐÎÞ·ûºÏÌõ¼þµÄ¼Ç¼ʱ½¨Òé²»ÒªÓÃSELECT COUNT £¨*£©ºÍselect top 1 Óï¾ä¡£
6. ʹÓÃÄÚ²ãÏÞ¶¨ÔÔò£¬ÔÚƴдSQLÓï¾äʱ£¬½«²éѯÌõ¼þ·Ö½â¡¢·ÖÀ࣬
²¢¾¡Á¿ÔÚSQLÓï¾äµÄ×îÀï²ã½øÐÐÏÞ¶¨£¬ÒÔ¼õÉÙÊý¾ÝµÄ´¦ÀíÁ¿¡£
7. Ó¦¾ø¶Ô±ÜÃâÔÚorder by×Ó¾äÖÐʹÓñí´ïʽ¡£
8. Èç¹ûÐèÒª´Ó¹ØÁª±í¶ÁÊý¾Ý£¬¹ØÁªµÄ±íÒ»°ã²»Òª³¬¹ý7¸ö¡£
9. СÐÄʹÓà IN ºÍ OR£¬ÐèҪעÒâIn¼¯ºÏÖеÄÊý¾ÝÁ¿¡£½¨Ò鼯ºÏÖеÄÊý¾Ý²»³¬¹ý200¸ö¡£
10. <> Óà < ¡¢ > ´úÌ棬>ÓÃ>=´úÌ棬<ÓÃ<=´úÌ棬ÕâÑù¿ÉÒÔÓÐЧµÄÀûÓÃË÷Òý¡£
11. ÔÚ²éѯʱ¾¡Á¿¼õÉÙ¶Ô¶àÓàÊý¾ÝµÄ¶ÁÈ¡°üÀ¨¶àÓàµÄÁÐÓë¶àÓàµÄÐС£
12. ¶ÔÓÚ¸´ºÏË÷ÒýҪעÒ⣬ÀýÈçÔÚ½¨Á¢¸´ºÏË÷ÒýʱÁеÄ˳ÐòÊÇF1£¬F2£¬F3£¬
ÔòÔÚwhere»òorder by×Ó¾äÖÐÕâЩ
Ïà¹ØÎĵµ£º
Ò».×¢ÊÍ
-- µ¥ÐÐ×¢ÊÍ£¬´ÓÕâµ½±¾ÐнáÊøΪעÊÍsql Óï·¨£¬ÀàËÆC++£¬c#ÖÐ//
/* ¡ */ ¶àÐÐ×¢ÊÍ£¬ÀàËÆC++£¬C#ÖÐ/* ¡ */
¶þ.±äÁ¿£¨int£¬ smallint£¬ tinyint£¬ decimal£¬float£¬real£¬ money £¬smallmoneysql Óï·¨£¬ text £¬image£¬ char£¬ varchar¡£¡£¡£¡£¡£¡££©
Óï·¨£º
DECLARE
&nb ......
ÿÌ죬ÿÖܵÄÖ´ÐÐ
±ÈÈç¿ÉÒÔ¿ØÖÆÿÌìÖ»ÄÜͶƱÈý´Î¡£
ÿÖÜҪͳ¼ÆÒ»ÏÂͶƱÊý¡£
1¡¢Äã±ØÐ뿪Æô´úÀí·þÎñsql server agent
2¡¢ÔÚÆóÒµ¹ÜÀíÆ÷À´ò¿ª“¹ÜÀí—>sqlserver´úÀí—>×÷Òµ”£¬ÐÂÔö×÷Òµ£¬Ð½¨“²½Ö蔣¬ÔÚ²½ÖèÀïÌîÈëÄãҪתÒƵÄSQLÓï¾äµ½“ÃüÁòÀȻºóн¨“µ ......
Ê×Ïȸø³öÁ½ÕŲâÊÔ±í
a(aid int, adata varchar(20)) b(bid int, bdata varchar(20))
1.join Óë inner join
Ö´ÐÐÈçÏÂÓï¾ä£º
select * from a join b on a.aid = b.bid;
ÎÒÃÇ»áµÃµ½ÈçϵĽá¹û£º
AID ADAT ......
ÓÉÓÚϵͳÐèÇó£¬×î½üÔÚ¿ª·¢¹ý³ÌÖн«ÏµÍ³´ÓÔÀ´µÄMySQLתÒƵ½SQL
2000Ï£¬ÆäÖÐÓöµ½ÁËÖî¶àÎÊÌ⣬»¨·ÑÁËÎÒ²»ÉÙʱ¼ä¡£ÏÖÔÚ°ÑÎҵľÑéÄóöÀ´¸æËß´ó¼Ò£¬ºÃÈôó¼ÒÉÙ×ßÍä·£¬½ÚԼʱ¼ä¡£
¡¡¡¡Ê×ÏÈÊÇSQL
2000Êý¾Ý¿âµÄ°²×°ÎÊÌ⣬ÔÚ´ËÎÒÖ÷Òª½²Ð©¹ØÓÚSQL 2000µÄ°æ±¾Óë²Ù×÷ϵͳµÄ¼æÈÝÐÔÎÊÌ⣺SQL
2000×ܹ²ÓÐ7¸ö²»Í¬°æ±¾£¬ÊÊ ......
Ò»¡¢ ¼òµ¥²éѯ
¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable
WHERE name='ÕÅÈý'
(Ò») Ñ¡ÔñÁÐ ......