£Ó£Ñ£Ì Óï·¨²Î¿¼ÊÖ²á
DB2 ÌṩÁ˹ØÁ¬Ê½×ÊÁÏ¿âµÄ²éѯÓïÑÔ £Ó£Ñ£Ì (Structured Query Language)£¬ ÊÇÒ»Öַdz£¿ÚÓﻯ¡¢¼ÈÒ×ѧÓÖÒ׶®µÄÓï·¨¡£´ËÒ»ÓïÑÔ¼¸ºõÊÇÿ¸ö×ÊÁÏ¿âϵͳ¶¼ ±ØÐëÌṩµÄ£¬ÓÃÒÔ±íʾ¹ØÁ¬Ê½µÄ²Ù×÷£¬°üº¬ÁË×ÊÁϵĶ¨Ò壨£Ä£Ä£Ì£©ÒÔ¼°×ÊÁÏ µÄ´¦Àí£¨£Ä£Í£Ì£©¡£SQLÔÀ´Æ´³É SEQUEL£¬ÕâÓïÑÔµÄÔÐÍÒÔ¡°ÏµÍ³ R¡°µÄÃû ×ÖÔÚ IBM Ê¥ºÉÎ÷ʵÑéÊÒÍê³É£¬¾¹ý IBM ÄÚ²¿¼°ÆäËûµÄÐí¶àʹÓÃÐÔ¼°Ð§ÂʲâÊÔ£¬ Æä½á¹ûÏ൱ÁîÈËÂúÒ⣬²¢¾ö¶¨ÔÚϵͳR µÄ¼¼Êõ»ù´¡·¢Õ¹³öÀ´ IBM µÄ²úÆ·¡£¶ø ÇÒÃÀ¹ú¹ú¼Ò±ê׼ѧ»á£¨ANSI£©¼°¹ú¼Ê±ê×¼»¯×éÖ¯£¨ISO¡¡ÔÚ 1987 ×ñÑÒ»¸ö¼¸ºõ ÊÇÒÔ IBM SQL Ϊ»ù´¡µÄ±ê×¼¹ØÁ¬Ê½×ÊÁÏÓïÑÔ¶¨Òå¡£ »ù±¾²éѯ
SELECT column1,columns2,... FROM table_name ˵Ã÷£º°Ñtable_name µÄÌض¨À¸Î»×ÊÁÏÈ«²¿ÁгöÀ´ SELECT * FROM table_name WHERE column1 = xxx [AND column2 > yyy] [OR column3 <> zzz] ˵Ã÷£º 1.*±íʾȫ²¿µÄÀ¸Î»¶¼ÁгöÀ´ 2.WHERE Ö®ááÊǽÓÌõ¼þʽ£¬°Ñ·ûºÏÌõ¼þµÄ×ÊÁÏÁгöÀ´ SELECT column1,column2 FROM table_name ORDER BY column2 [DESC] ˵Ã÷£º ORDER BY ÊÇÖ¸¶¨ÒÔij¸öÀ¸Î»×öÅÅÐò£¬[DESC]ÊÇÖ¸´Ó´óµ½Ð¡ÅÅÁУ¬Èô ûÓÐÖ¸Ã÷£¬ÔòÊÇ´ÓСµ½´óÅÅÁÐ ×éºÏ²éѯ ×éºÏ²éѯÊÇÖ¸Ëù²éѯµÃ×ÊÁÏÀ´Ô´²¢²»Ö»Óе¥Ò»µÄ±í¸ñ£¬¶øÊÇÁªºÏÒ»¸öÒÔÉϵıí¸ñ²ÅÄܹ»µÃµ½½á¹ûµÄ¡£
SELECT * FROM table1,table2 WHERE table1.colum1=table2.column1 ˵Ã÷£º 1.²éѯÁ½¸ö±í¸ñÖÐÆäÖÐ column1 ÖµÏàͬµÄ×ÊÁÏ 2.µ±È»Á½¸ö±í¸ñÏ໥±È½ÏµÄÀ¸Î»£¬Æä×ÊÁÏÐÎ̬±ØÐëÏàͬ 3.Ò»¸ö¸´ÔӵIJéѯÆ䶯Óõ½µÄ±í¸ñ¿ÉÄÜ»áºÜ¶à¸ö ÕûºÏÐԵIJéѯ£º
SELECT COUNT (*) FROM table_name WHERE column_name = xxx ˵Ã÷£º ²éѯ·ûºÏÌõ¼þµÄ×ÊÁϹ²Óм¸±Ê SELECT SUM(column1) FROM table_name ˵Ã÷£º 1.¼ÆËã³ö×ܺͣ¬ËùÑ¡µÄÀ¸Î»±ØÐëÊÇ¿ÉÊýµÄÊý×ÖÐÎ̬ 2.³ý´ËÒÔÍ⻹ÓÐ AVG() ÊǼÆËãƽ¾ù¡¢MAX()¡¢MIN() ¼ÆËã×î´ó×îСֵµÄÕûºÏÐÔ²éѯ SELECT column1,AVG(column2) FROM table_name GROUP BY column1 HAVING AVG(column2) > xxx ˵Ã÷£º 1.GROUP BY: ÒÔcolumn1 Ϊһ×é¼ÆËã column2 µÄƽ¾ùÖµ ±ØÐëºÍ AVG¡¢SUM µÈÕûºÏÐÔ²éѯµÄ¹Ø¼ü×ÖÒ»ÆðʹÓà 2.HAVING : ±ØÐëºÍ GROUP BY Ò»ÆðʹÓÃ×÷ΪÕûºÏÐÔµÄÏÞÖÆ ¸´ºÏÐԵIJéѯ
SELECT * FROM table_name1 WHERE EXISTS ( SELECT * FROM table_name2 WHERE conditions ) ˵Ã÷£º 1.WHERE µÄ conditions ¿ÉÒÔÊÇÁíÍâÒ»¸öµÄ query 2.EXISTS ÔÚ´ËÊÇÖ¸´æÔÚÓë·ñ SELECT * FROM table_name1 WHERE column1 IN ( SELECT column1 FROM table_name2 WHERE conditions ) ˵Ã÷¡¡ 1. IN ááÃæ½ÓµÄÊÇÒ»¸ö¼¯ºÏ£¬±íʾcolumn1 ´æÔÚ¼¯ºÏÀïÃæ 2. SELECT ³öÀ´µÄ×ÊÁÏÐÎ̬±ØÐë·ûºÏ column1 </P><P>ÆäËû²éѯ SELECT * FROM table_name1 WHERE column1 LIKE x% ˵Ã÷£º 1.LIKE ±ØÐëºÍááÃæµÄx% ÏàºôÓ¦±íʾÒÔ xΪ¿ªÍ·µÄ×Ö´® SELECT * FROM table_name1 WHERE column1 IN (xxx,yyy,..) ˵Ã÷¡¡ 1. IN ááÃæ½ÓµÄÊÇÒ»¸ö¼¯ºÏ£¬±íʾcolumn1 ´æÔÚ¼¯ºÏÀïÃæ SELECT * FROM table_name1 WHERE column1 BETWEEN xx AND yy ˵Ã÷¡¡ 1. BETWEEN ±íʾ column1 µÄÖµ½éì¶ xx ºÍ yy Ö®¼ä ¸ü¸Ä×ÊÁÏ£º UPDATE table_name SET column1=xxx WHERE conditoins ˵Ã÷£º 1.¸ü¸Äij¸öÀ¸Î»É趨ÆäֵΪxxx 2.conditions ÊÇËùÒª·ûºÏµÄÌõ¼þ¡¢ÈôûÓÐ WHERE Ôò Õû¸ö table µÄÄǸöÀ¸Î»¶¼»áÈ«²¿±»¸ü¸Ä
ɾ³ý×ÊÁÏ£º DELETE FROM table_name WHERE conditions ˵Ã÷£ºÉ¾³ý·ûºÏÌõ¼þµÄ×ÊÁÏ
--------------------------------------------------------------------------------
Ïà¹ØÎÄÕÂ
ÈçºÎÄÜͨ¹ý´°Ìå·ÃÎÊ±í£¬µ«²»ÄÜÖ±½Ó¶ÁÈ¡±í£¿ 2004-8-27 21:58:17
Êý¾Ý¿âÉè¼ÆÖеÄÃô½Ý·½·¨ 2004-2-9 11:19:16
µ÷ÓÃoutlookÉú³É²¢·¢ËÍÓʼþµÄ´úÂë 2004-1-30 10:32:07
SQL SERVER»ù±¾¸ÅÄîѧϰӡÏó 2004-1-1 21:23:13
Ò»×éSQL ServerÉí·ÝÑéÖ¤¹ÜÀí×Ó³ÌÐò 2003-12-31 16:29:54
Access Êý¾Ý¿âºÍ Access ÏîÄ¿Ö®¼äµÄÊý¾ÝÀàÐ͵ıȽϻòÓ³Éä 2003-12-26 14:20:19
´óÐÍÊý¾Ý¿âÉè¼ÆÔÔò 2003-12-15 12:49:18
ERwin--¼ò»¯µÄÊý¾Ý¿âÉè¼Æ¹¤¾ß 2003-12-15 12:41:40
ERwinÈí¼þ¼ò½é 2003-12-15 12:39:55
¾µä×Ó²éѯӦÓà 2003-11-17 8:54:51
Á˽â Microsoft Access °²È«ÐÔ 2003-11-13 11:21:08
²»µ±±àдSQLÓï¾äµ¼ÖÂϵͳ²»°²È« 2003-11-13 10:55:26
±ÜÃâAccessºÍSQL ServerµÄ¿ÕÖµ³åÍ» 2003-10-17 20:03:19
±í´ïʽÉú³ÉÆ÷Öеļ¸ÖÖ³£Ó÷ûºÅ 2003-10-17 19:55:56
´´½¨ÍêÃÀ±¨±í 2003-10-17 19:37:17
SQL SERVER ÓëACCESS¡¢EXCELµÄÊý¾Ýת»» 2003-10-17 19:12:00
´æ´¢¹ý³ÌÈëÃÅ 2003-10-17 19:06:48
MS Jet SQL for Access 2000Öм¶Æª(IV) 2003-10-17 18:52:20
MS Jet SQL for Access 2000Öм¶Æª (III) 2003-10-17 18:51:47
MS Jet SQL for Access 2000Öм¶Æª (II) 2003-10-17 18:51:01
MS Jet SQL for Access 2000Öм¶Æª (I) 2003-10-17 18:47:38
ʹÓÃADOÁ¬½Óµ½·À»ðǽºóµÄSQL Server 2003-10-17 18:43:57
ADOÁ¬½ÓÊý¾Ý¿â×Ö·û´®´óÈ« 2003-10-17 18:40:47
ADOÈý´ó¶ÔÏóµÄÊôÐÔ¡¢·½·¨¡¢Ê¼þ¼°³£Êý£¨¶þ£© 2003-10-14 8:45:33
ADOÈý´ó¶ÔÏóµÄÊôÐÔ¡¢·½·¨¡¢Ê¼þ¼°³£Êý£¨Èý£© 2003-10-14 8:44:20
ADOÈý´ó¶ÔÏóµÄÊôÐÔ¡¢·½·¨¡¢Ê¼þ¼°³£Êý£¨Ò»£© 2003-10-14 8:43:26
ACCESSÊý¾Ý·ÃÎÊÒ³ÅäÖÃʵÀý 2003-10-14 8:36:00
ÌáÉýÇ°ºǫ́ģʽ³ÌÐòµÄËÙ¶È 2003-10-10 10:17:08
AccessÆô¶¯ÃüÁîÐÐÑ¡Ïî´óÈ« 2003-10-10 10:02:00
Ò»¸ö¼òµ¥µÄAdoÓ÷¨Ê¾Àý 2003-10-6 16:24:38
Access 2002 ÖеÄÃû³Æ×Ô¶¯¸üÕý˵Ã÷ 2003-10-6 15:16:24
Êý¾Ý¿âÓ¦ÓóÌÐòÐè×¢ÒâµÄÎÊÌâ 2003-10-6 11:11:06
|