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

SQL Server: Inner Join¼°Outer Join, Natrual Jion

Ò»¡¢NATURAL JOIN£¨×ÔÈ»Á¬½Ó£©
     Á½Õűíͨ¹ýNATURAL JOINÁ¬½ÓµÄʱºò£¬Ï൱ÓÚÓиöÒþº¬µÄWHERE×Ӿ䣬¶ÔÁ½ÕűíÖÐͬÃûµÄ¶ÔÓ¦ÁÐÏà±È½Ï¿´ÊÇ·ñÏàµÈ¡£
¶þ¡¢CROSS JOIN£¨´´½¨µÑ¿¨¶û»ý£©
     ¶ÔÁ½Õűíͨ¹ý½»²æÁªºÏ²úÉúµÚÈýÕÅ·µ»Ø½á¹û¼¯µÄ±í¡£Ï൱ÓÚÆÕͨµÄÁ¬½Ó¡£
Èý¡¢INNER JOIN£¨ÄÚÁ¬½Ó£©
   ÄÚÁ¬½Ó¾ÍÏ൱ÓÚÆÕͨµÄCROSS JOIN£¬Ö»ÊǸñʽ²»Ò»Ñù£¬INNER JOINÔÚºóÃæÓÐÒ»¸öON×Ӿ䣨Ï൱ÓÚWHERE£©µÄËÑË÷Ìõ¼þ£¬ÓÃÓÚ¹ýÂË·µ»ØµÄÐС£
ËÄ¡¢OUTER JOIN £¨ÍâÁ¬½Ó£©
   select * from ta outer join tb on (ta.c1=tb.c1)
     outer join¸æËßDBMSÉú³É½á¹û±í£¬Ôڴ˱íÖв»½ö´øÓÐÏà¹Ø(ta.c1=tb.c1)Ðжԣ¬¶øÇÒ»¹ÓÐÀ´×ÔÁ½¸öÔ´±íÖÐÈÎÒ»±íµÄ²»Æ¥ÅäµÄÐС£
Îå¡¢LEFT OUTER JOIN£¨×óÁ¬½Ó£© RIGHT OUTER JOIN£¨ÓÒÁ¬½Ó£©
     select * from ta left outer join   tb on (ta.c1=tb.c1)
       select * from ta right outer join tb on (ta.c1=tb.c1)
       left outer join(left join) ¸æËßDBMSÉú³É°üÀ¨ÁªºÏÐкÍÈκβ»Æ¥ÅäµÄÐеĽá¹û±í£¬µ«ÊDz»Æ¥ÅäµÄÐÐϵÀ´×Ô²éѯµÄfrom×Ó¾äÖÐLEFT OUTER JOIN¹Ø¼ü´Ê×ó±ßµÄ±íÖС£
     right outer join(right join)Óëleft outer join(left join)¸ÕºÃÏà·´¡£
Áù¡¢FULL OUTER JOIN£¨È«Á¬½Ó£©
   FULL OUTER JOIN ·µ»Ø×éºÏÁËLEFT OUTER JOIN ºÍRIGHT OUTER JOIN½á¹ûµÄ±í¡£
ÒÔÏÂÊÇInner Join¼°Outer JoinµÄ¾ßÌå½éÉÜ£º
ÔÚÒ»¸öÕý¹æ»¯µÄÊý¾Ý¿â»·¾³ÖÐ, ÎÒÃdz£»áÅöµ½Õâ¿îÇéÐÎ: ËùÐèµÄ×ÊÁϲ¢²»ÊÇ·ÅÔÚͬһ¸ö×ÊÁϱíÖÐ, ÔÚÕâ¸öʱºò, Äã¾ÍÒªÓõ½ Join¡£
¡¡¡¡µ±È» Join ÈçºÎ½«²»Í¬µÄÊý¾Ý¿âµÄ×ÊÁϽáºÏ, »¹Òª¿´ÄãÈçºÎʹÓÃËü, Ò»¹²ÓÐËÄÖÖ²»Í¬µÄ Join µÄ·½Ê½, ÔÚÕâƪÎÄÕÂÖÐÎÒÃǽ«ÎªÄã½éÉÜ Inner Join ¼° Outer Join ÒÔ¼°ÆäÓ¦Óá£
¡¡¡¡Inner Join
¡¡¡¡Inner Join Ó¦¸ÃÊÇ×î³£ÓÃµÄ Join ·½Ê½, ËüÖ»»á´«»Ø·ûºÏ Join ¹æÔòµÄ¼Í¼, »¹ÊÇÏÈÀ´¿´¿´Óï·¨£º
Select <ҪѡÔñµÄ×Ö¶Î> from <Ö÷Òª×ÊÁϱí> <Join ·½Ê½> <´ÎÒª×ÊÁϱí> [On <Join ¹æÔò>]
¡¡¡¡ÏÖÔÚÎÒÃÇÀûÓà MS SQL ÄÚ½¨µÄ±±·çÊý¾Ý¿âÀ´Êµ¼ÊÁ·Ï°Ò»ÏÂ! Ïë¶àÁ˽â MS SQL µÄÄÚ½¨Êý¾Ý¿â, Äã¿ÉÒÔ¿´¿´ SQL Server µÄÄÚ½¨Êý¾Ý¿âÕâƪÎÄÕ¡£
¡¡¡¡Çë´ò¿ª


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

sql serverÖеÄconvertÈÕÆÚ¸ñʽ»¯´óÈ«

CONVERT
½«Ä³ÖÖÊý¾ÝÀàÐ͵ıí´ïʽÏÔʽת»»ÎªÁíÒ»ÖÖÊý¾ÝÀàÐÍ¡£ÓÉÓÚijЩÐèÇó¾­³£Óõ½È¡ÈÕÆÚ¸ñʽµÄ²»Í¬.ÏÖÒÔÏ¿ÉÔÚ
SQL ServerÖС¡½«ÈÕÆÚ¸ñʽ»¯.
SQL Server Ö§³ÖʹÓÿÆÍþÌØËã·¨µÄ°¢À­²®ÑùʽÖеÄÊý¾Ý¸ñʽ¡£
ÔÚ±íÖУ¬×ó²àµÄÁ½Áбíʾ½« datetime »ò smalldatetime ת»»Îª×Ö·ûÊý¾ÝµÄ style Öµ¡£¸ø style Öµ¼Ó 100£¬¿É»ñµÃ°üÀ¨Ê ......

SQL SERVER CEÖÐ ²éѯÓï¾ä±äÁ¿µÄʹÓÃ

ÒòΪ²»Ö§³Ö´æ´¢¹ý³Ì£¬ËùÒÔ²éѯÓï¾äÈçÏ£º
string SLQuery =
                "INSERT INTO ParkLocation(ParkName,Latitude, Longtitude,Charge,TotalSpace,EmptySpace,ParkCaption,UpdataTime)"+
      &nb ......

SQL JOIN

SQL JOIN
 
SQL join ÓÃÓÚ¸ù¾ÝÁ½¸ö»ò¶à¸ö±íÖеÄÁÐÖ®¼äµÄ¹Øϵ£¬´ÓÕâЩ±íÖвéѯÊý¾Ý¡£
Join ºÍ Key
ÓÐʱΪÁ˵õ½ÍêÕûµÄ½á¹û£¬ÎÒÃÇÐèÒª´ÓÁ½¸ö»ò¸ü¶àµÄ±íÖлñÈ¡½á¹û¡£ÎÒÃǾÍÐèÒªÖ´ÐÐ join¡£
Êý¾Ý¿âÖеıí¿Éͨ¹ý¼ü½«±Ë´ËÁªÏµÆðÀ´¡£Ö÷¼ü£¨Primary Key£©ÊÇÒ»¸öÁУ¬ÔÚÕâ¸öÁÐÖеÄÿһÐеÄÖµ¶¼ÊÇΨһµÄ¡£ÔÚ±íÖУ¬Ã¿¸öÖ÷¼üµÄ ......

SQL RIGHT JOIN ¹Ø¼ü×Ö

SQL RIGHT JOIN ¹Ø¼ü×Ö
SQL RIGHT JOIN ¹Ø¼ü×Ö
RIGHT JOIN ¹Ø¼ü×Ö»áÓÒ±í (table_name2) ÄÇÀï·µ»ØËùÓеÄÐУ¬¼´Ê¹ÔÚ×ó±í (table_name1) ÖÐûÓÐÆ¥ÅäµÄÐС£
RIGHT JOIN ¹Ø¼ü×ÖÓï·¨
SELECT column_name(s)
from table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
×¢ÊÍ£ºÔÚijЩÊý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ