Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sql²éѯÓï¾äÖÐ inºÍ existsµÄÇø±ðÓëÐÔÄܱȽÏ

¶ÔInºÍexistsµÄÐÔÄܽøÐбȽϣ¬Ê×ÏÈÒªÖªµÀËüÃÇÁ½ÕßµÄÇø±ð¡£
in: È·¶¨¸ø¶¨µÄÖµÊÇ·ñÓë×Ó²éѯÖеÄÖµ»òÁбíÖеÄÖµÏàÆ¥Åä¡£
exists: Ö¸¶¨Ò»¸ö×Ó²éѯ£¬¼ì²âÐÐÊÇ·ñ´æÔÚ¡£
¿É·ÖÎöËüÃǵIJéѯÓï¾äÀ´µÃ³öÕæÊµµÄ²î±ð:
in
±ÈÈçSelect * from t1 where x in ( select y from t2 )
Ö´ÐеĹý³ÌÏ൱ÓÚ:
select *
  from t1, ( select distinct y from t2 ) t2
where t1.x = t2.y;
exists
±ÈÈçselect * from t1 where exists ( select t2.z from t2 where y = x )
Ö´ÐеĹý³ÌÏ൱ÓÚ:
for t in ( select * from t1 )
   loop
      if ( exists ( select t2.z from t2 where y = t.x )
      then
         OUTPUT THE RECORD
      end if
end loop
´ÓÉÏÃæµÄÓï¾ä¿ÉÒÔ¿´³ö£¬¶Ôt1±í²»¿É±ÜÃâµÄ½øÐÐÁËÒ»´ÎÈ«ÅÌɨÃè
inºÍexists
in ÊǰÑÍâ±íºÍÄÚ±í×÷hash Á¬½Ó£¬¶øexistsÊǶÔÍâ±í×÷loopÑ­»·£¬Ã¿´ÎloopÑ­»·ÔÙ¶ÔÄÚ±í½øÐвéѯ¡£
Ò»Ö±ÒÔÀ´ÈÏΪexists±ÈinЧÂʸߵÄ˵·¨ÊDz»×¼È·µÄ¡£
Èç¹û²éѯµÄÁ½¸ö±í´óСÏ൱£¬ÄÇôÓÃinºÍexists²î±ð²»´ó¡£
Èç¹ûÁ½¸ö±íÖÐÒ»¸ö½ÏС£¬Ò»¸öÊÇ´ó±í£¬Ôò×Ó²éѯ±í´óµÄÓÃexists£¬×Ó²éѯ±íСµÄÓÃin£º
ÀýÈ磺±íA£¨Ð¡±í£©£¬±íB£¨´ó±í£©
1£º
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Òª¿ì¡£ 
 


Ïà¹ØÎĵµ£º

¶ÀÁ¢µÄSQL ½Å±¾¹¤¾ß:QweryBuilder

ÍøÕ¾£ºhttp://werysoft.com/
Èç¹ûÄú±ØÐë¹ÜÀí»·¾³ÖеĶàÖÖÀàÐ͵ÄÊý¾Ý¿â·þÎñÆ÷£¬ÔòʹÓü¯ÖÐʽ¹¤¾ßµ÷ÕûËùÓÐÊý¾Ý¿â¿ÉÄÜ»á±È½Ï·½±ã¡£Werysoft µÄ QweryBuilder Ö¼ÔÚΪÄúÌṩ´ËÏÄÜ¡£Äú¿ÉÒÔʹÓÃËü´Óͬһ GUI Á¬½Óµ½ Microsoft SQL Server¡¢Sybase ASE¡¢SQL Anywhere ºÍ Oracle ʵÀý£¬È»ºó²é¿´¡¢´´½¨¡¢¸üкÍɾ³ýÊý¾Ý¿â½Å±¾¡¢¼Ü ......

SQL Server 2000 µÄϵͳÊý¾Ý¿â

SQL Server 2000 µÄϵͳÊý¾Ý¿â
SQL Server 2000·þÎñÆ÷°²×°ºó»á½¨Á¢4ϵͳÊý¾Ý¿â¡£·Ö±ðÊÇmaster¡¢model¡¢msdb¡¢tempdb¡£
1¡¢masterÊý¾Ý¿â
    masterÊý¾Ý¿âÊÇSQL Server 2000ÖÐ×îÖØÒªµÄÊý¾Ý¿â£¬¼Ç¼ÁËSQL Server 2000µÄ·þÎñÆ÷¼¶ÏµÍ³ÐÅÏ¢£¬°üÀ¨ËùÓÐÕË»§ºÍÃÜÂ룬´ÅÅ̿ռ䡢Îļþ·ÖÅäºÍʹÓá¢ÏµÍ³¼¶µÄÅäÖòÎÊý¡ ......

LINQ to SQL ѧϰreference

http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx
1-9 parts are the most useful knowledge for you so far. ......

c#Æô¶¯Sql Server·þÎñ

³ÌÐòÆô¶¯Sql ServerÆäʵºÜ¼òµ¥
´úÂ룺
System.ServiceProcess.ServiceController   myController   =
new   System.ServiceProcess.ServiceController("MSSQL$ACCP4444"); //·þÎñÃû³Æ ÕÒÁ˰ëÌì²ÅÕÒµ½£¬±¿ËÀÎÒÍêÁË¡£ÔÚ·þÎñÉÏÓÒ¼üÊôÐÔ£¬ÄÜ¿´µ½
if (myController.CanStop)
{ }
else ......

SQLÈ¡ÈÕÆÚ

SQLÈ¡ÈÕÆÚ
SQL Server 2009-11-19 15:07:30 ÔĶÁ7 ÆÀÂÛ0 ×ֺţº´óÖÐС
·½·¨Ò»:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),\'-\',\'\'),\' \',\'\'),\':\',\'\')
20040912110608
select CONVERT(varchar(12) , getdate( ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ