SQLÖеÄinºÍexistsµÄÇø±ð
ÔÚÍøÉÏ¿´µ½Ò»¸öºÜºÃµÄÀý×Ó½²½âinºÍexistsµÄÇø±ð£¬ÕâÀﱸÍüÏ¡£
±¾Ê¾ÀýËùʾ²éѯ²éÕÒÓÉλÓÚÒÔ×Öĸ B ¿ªÍ·µÄ³ÇÊÐÖеÄÈÎÒ»³ö°æÉ̳ö°æµÄÊéÃû£º
USE pubs
SELECT title
from titles WHERE EXISTS
(SELECT *
from publishers
WHERE pub_id = titles.pub_id
AND city LIKE 'B%')
GO
-- Or, using IN:
USE pubs
GO
SELECT title
from titles
WHERE pub_id IN
(SELECT pub_id
from publishers
WHERE city LIKE 'B%')
GO
ʹÓà NOT EXISTS
NOT EXISTS µÄ×÷ÓÃÓë EXISTS ÕýÏà·´¡£Èç¹û×Ó²éѯûÓзµ»ØÐУ¬ÔòÂú×ã NOT EXISTS ÖÐµÄ WHERE ×Ӿ䡣±¾Ê¾Àý²éÕÒ²»³ö°æÉÌÒµÊé¼®µÄ³ö°æÉ̵ÄÃû³Æ£º
USE pubs
GO
SELECT pub_name
from publishers
WHERE NOT EXISTS
(SELECT *
from titles
WHERE pub_id = publishers.pub_id
AND type = 'business')
ORDER BY pub_name
GO
inºÍexists
in ÊÇ°ÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ»·£¬Ã¿´ÎloopÑ»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£
Èç¹ûÁ½¸ö±íÖÐÒ»¸ö½ÏС£¬Ò»¸öÊÇ´ó±í£¬Ôò×Ó²éѯ±í´óµÄÓÃexists£¬×Ó²éѯ±íСµÄÓÃin£º
ÀýÈ磺±íA£¨Ð¡±í£©£¬±íB£¨´ó±í£©£ºselect * from A where cc in (select cc from B)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý£»select * from A where exists(select cc from B where cc=A.cc)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý¡£
Ïà·´µÄ2£ºselect * from B where cc in (select cc from A)
ЧÂʸߣ¬Óõ½ÁËB±íÉÏccÁеÄË÷Òý£»select * from B where exists(select cc from A where cc=B.cc)
ЧÂʵͣ¬Óõ½ÁËA±íÉÏccÁеÄË÷Òý¡£
not in ºÍnot existsÈç¹û²éѯÓï¾äʹÓÃÁËnot in ÄÇôÄÚÍâ±í¶¼½øÐÐÈ«±íɨÃ裬ûÓÐÓõ½Ë÷Òý£»¶ønot extsts µÄ×Ó²éѯÒÀÈ»ÄÜÓõ½±íÉϵÄË÷Òý¡£ËùÒÔÎÞÂÛÄǸö±í´ó£¬ÓÃnot exists¶¼±Ènot inÒª¿ì¡£
in Óë =µÄÇø±ð
select name from student where name in ('zhang','wang','li','zhao');
Óë
select name from student where name='zhang' or name='li' or name='wang' or name='zhao'
Ïà¹ØÎĵµ£º
ÀýÈçÎÊÌ⣺ÏÖÔÚÄãÃæ¶ÔÒ»Õűí table1 , table1ÖÐÓиö×Ö¶ÎΪsales_salary £¬ÔÚÊý¾Ý¿â´æ·ÅµÄ×Ö¶ÎΪint ÀàÐÍ ¡£
ÒªÇó£¬Äãͳ¼ÆµÄ½á¹ûµ¥Î»£¨ÍòÔª£©£¬±£Áô2λСÊý¡£²¢ÇÒ»áÓÐÕâÑùµÄµÈʽ £¨1ÐУ«2ÐУ½3ÐУ½7ÐУ«8ÐУ© Ãæ¶ÔÕâÑùµÄÎÊÌ⣬½â¾öµÄ·½°¸Óкܶࡣ±ÈÈ磬Äã¿ÉÒÔͨ¹ýÊÓͼµÄ·½°¸À´½â¾ö£¬»ò¿ØÖÆÊäÈëÓò ...
µ«ÓÐÒ»ÖÖµÈЧ¿ØÖÆÊäÈë ......
ÔÚ°²×°SQL Server 2005¿ª·¢°æʱ³öÏÖÎÊÌâ¡£°²×°»·¾³Îªwindows xp sp3£¬°²×°Óû§Ê¹Ó󬼶¹ÜÀíÔ±£¨Administrator£©¡£³öÏֵĴíÎóÊÇ
ÔÚ°²×°“Integration Services”²½Öèʱ³öÏÖ°²×°´íÎó£¬Ìáʾ“´íÎó: -2146233087”¡£
´íÎó¼Ç¼
±êÌâ:
Microsoft SQL Server 2005 °²×°³ÌÐò
ÎÞ·¨ÔÚ COM+ Ŀ¼Öа²×°ºÍÅäÖ ......
ÔÚVisual Studio 2008 ÖÐʹÓÃO/RÉè¼ÆÆ÷£º
µãÌí¼ÓÏîÄ¿£¬Ñ¡Ôñ´´½¨Linq to SQLÏîÄ¿£¬Ê¹Ó÷þÎñÆ÷×ÊÔ´¹ÜÀíÆ÷Á¬½ÓNorthwindÊý¾Ý¿â£¬½«CustomersºÍOrdersÁ½¸ö±íÍϵ½Éè¼Æ½çÃæÉÏ£¬ÏµÍ³»á×Ô¶¯´´½¨app.configºÍNorthwid.designer.cs,Ç°ÕßÊÇÅäÖÃÁ¬½ÓÊý¾Ý¿âµÄÁ¬½Ó×Ö´®£»ºóÕß»áÉú³ÉÒ»¸ö¼Ì³Ð×ÔDataContextµÄÀࣺNorthwindDataContext¡£
......
sql ·þÎñÆ÷½ÇÉ« Êý¾Ý¿â½ÇÉ«
·þÎñÆ÷½ÇÉ«
ËùÓеķþÎñÆ÷½ÇÉ«¶¼ÊÇ“¹Ì¶¨µÄ”½ÇÉ«£¬²¢ÇÒ£¬´ÓÒ»¿ªÊ¼¾Í´æÔÚÓÚÄÇÀï——×Ô°²×°ÍêSQL ServerµÄÄÇÒ»¿ÌÆð£¬Ä㽫ӵÓеÄËùÓзþÎñÆ÷½ÇÉ«¾ÍÒѾ´æÔÚÁË¡£
½Ç¡¡¡¡É«
ÌØ¡¡¡¡ÐÔ
sysadmin
¸Ã½ÇÉ«Äܹ»Ö´ÐÐSQL ServerÉϵÄÈκβÙ× ......
Èç¹ûÄãµÄÉí·ÝÑéÖ¤·½Ê½ÎªWindows¼¯³ÉÉí·ÝÑéÖ¤¸ü¸ÄΪ»ìºÏ·½Ê½µÄÉí·ÝÑéÖ¤£¬ÐèÒªÔÚSQL Server Configuration ManagementÖУ¬°ÑTCP/IPµÄ»î¶¯ÆôÓã¬Ò²¾ÍÊǵÚÒ»¸öÑ¡ÔñµÄµØ·½£¬Ñ¡ÔñÆôÓᣲ¢ÇÒʹÓü¯³ÉÉí·ÝÑéÖ¤·½Ê½µÇ¼ºó£¬ÔÚÊý¾Ý¿â·þÎñÆ÷ÉÏÑ¡ÔñÊôÐÔ£¬°Ñ°²È«ÐÔϵÄWINDOWSģʽ¸ÄΪSQLÓëWINDOWSģʽ ......