sqlÖÐinºÍexistÓï¾äµÄÇø±ð
IN
È·¶¨¸ø¶¨µÄÖµÊÇ·ñÓë×Ó²éѯ»òÁбíÖеÄÖµÏàÆ¥Åä¡£
EXISTS
Ö¸¶¨Ò»¸ö×Ó²éѯ£¬¼ì²âÐеĴæÔÚ¡£
±È½ÏʹÓà EXISTS ºÍ IN µÄ²éѯ
Õâ¸öÀý×ӱȽÏÁËÁ½¸öÓïÒåÀàËƵIJéѯ¡£µÚÒ»¸ö²éѯʹÓà EXISTS ¶øµÚ¶þ¸ö²éѯʹÓà IN¡£×¢ÒâÁ½¸ö²éѯ·µ»ØÏàͬµÄÐÅÏ¢¡£
USE pubs
GO
SELECT DISTINCT pub_name
from publishers
WHERE EXISTS
(SELECT *
from titles
WHERE pub_id = publishers.pub_id
AND type = 'business')
GO
-- Or, using the IN clause:
USE pubs
GO
SELECT distinct pub_name
from publishers
WHERE pub_id IN
(SELECT pub_id
from titles
WHERE type = 'business')
GO
ÏÂÃæÊÇÈÎÒ»²éѯµÄ½á¹û¼¯£º
pub_name
----------------------------------------
Algodata Infosystems
New Moon Books
(2 row(s) affected)
Ïà¹ØÎĵµ£º
·½·¨1£º
Ò»¡¢ÕÒÒ»ÕÅSQL server·þÎñÆ÷°æ¹âÅÌ£¬ÔÚ¹âÅÌÉÏÕÒµ½Ä¿Â¼“MSDE”²¢½øÈ룬ÔËÐÐSETUP.EXEÎļþ£¬²¢°´ÕÕ³ÌÐòÒªÇó½øÐа²×°¡£°²×°Íê³ÉÖØÐÂÆô¶¯¼ÆËã»ú¡£
¶þ¡¢ÔËÐйâÅÌÖеģ¬AUTORUN.EXEÎļþ£¬»òÈùâÅÌ×Ô¶¯ÔËÐУ¬´ò¿ª°²×°½çÃæºó£¬
µã»÷“°²×°SQL server 2000×é¼þ£¨C£©”-->“°²×°Êý¾Ý¿â·þÎñÆ ......
Ìá¸ßÊý¾Ý¿âSQLÓï¾ä²éѯËٶȵļ¸¸ö·½·¨
1¡¢³ÌÐòÖУ¬
±£Ö¤ÔÚʵÏÖ¹¦ÄܵĻù´¡ÉÏ£¬¾¡Á¿¼õÉÙ¶ÔÊý¾Ý¿âµÄ·ÃÎÊ´ÎÊý£»
ͨ¹ýËÑË÷²ÎÊý£¬¾¡Á¿¼õÉÙ¶Ô±íµÄ·ÃÎÊÐÐÊý,×îС»¯½á¹û¼¯£¬´Ó¶ø¼õÇáÍøÂ縺µ££»
Äܹ»·Ö¿ªµÄ²Ù×÷¾¡Á¿·Ö¿ª´¦Àí£¬Ìá¸ßÿ´ÎµÄÏìÓ¦Ëٶȣ»
ÔÚÊý¾Ý´°¿ÚʹÓÃSQLʱ£¬¾¡Á¿°ÑʹÓõÄË÷Òý·ÅÔÚÑ¡ÔñµÄÊ×ÁУ»
Ëã·¨µÄ½á¹¹¾¡Á¿¼òµ¥ ......
¾µäSQLÓï¾ä´óÈ«
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ ......
Êý¾ÝÀàÐͱȽÏ
ÀàÐÍÃû³Æ
Oracle
SQLServer
±È½Ï
×Ö·ûÊý¾ÝÀàÐÍ CHAR CHAR ¶¼Êǹ̶¨³¤¶È×Ö·û×ÊÁϵ«oracle ÀïÃæ×î´ó¶ÈΪ2kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
±ä³¤×Ö·ûÊý¾ÝÀàÐÍ VARCHAR2 VARCHAR Oracle ÀïÃæ×î´ó³¤¶ÈΪ 4kb£¬SQLServerÀïÃæ×î´ó³¤¶ÈΪ8kb
¸ù¾Ý×Ö·û¼¯¶ø¶¨µÄ¹Ì¶¨³¤¶È×Ö·û´® NCHAR NCHAR Ç°Õß×î´ó³¤¶È2kb ......
SQL Native Client ODBC Driver
±ê×¼°²È«Á¬½Ó
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
ÄúÊÇ·ñÔÚʹÓÃSQL Server 2005 Express ÇëÔÚ“Server”Ñ¡ÏîʹÓÃÁ¬½Ó±í´ïʽ“Ö÷»úÃû³Æ\SQLEXPRESS”¡£
ÊÜÐŵÄÁ¬½Ó
Driver={SQL Native ......