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

sql ±íÁ¬½Ó

TA:
1,WANG
2,ZHANG
4,LI
TB:
1,100
2,200
3,400
1.left join ×óÁ¬½Ó--ÒÔ×ó±íΪ»ù×¼£¬ÓÒ±íÖÐûֵµÄ£¬ÔÚ½á¹û¼¯ÖÐÒÔnullÖµ´úÌæ¡£(select * from TA left join TB where TA.ID=TB.ID)
   1,WANG,100
   2,ZHANG,200
   4,NULL
2.right join ÓÒÁ¬½Ó--ÒÔÓÒ±íΪ»ù×¼£¬×ó±íÖÐûֵµÄ£¬ÔÚ½á¹û¼¯ÖÐÒÔnullÖµ´úÌæ¡£(select * from TA right join TB where TA=TB)
   1,WANG,100
   2,ZHANG,200
   3,NULL,400
3.inner join ÄÚÁ¬½Ó--²éѯ×óÓÒ±íÖж¼ÓмüÖµÄÚÈÝ×öΪ½á¹û¼¯¡£ (select * from TA inner join TB where TA=TB)
   1,WANG,100
   2,ZHANG,200
  ±¸×¢£º ÄÚÁ¬½Ó¼òд£ºselect * from TA,TB WHERE TA.ID=TB.ID
¡¾µÑ¿¨¶û»ý¡¿£º
ʹÓý»²æÁª½Ó
ûÓÐ WHERE ×Ó¾äµÄ½»²æÁª½Ó½«²úÉúÁª½ÓËùÉæ¼°µÄ±íµÄµÑ¿¨¶û»ý¡£µÚÒ»¸ö±íµÄÐÐÊý³ËÒÔµÚ¶þ¸ö±íµÄÐÐÊýµÈÓڵѿ¨¶û»ý½á¹û¼¯µÄ´óС¡£ÏÂÃæÊÇÔÚsqlserver²éѯ·ÖÎöÆ÷ÖвâÊԵĽá¹û£º
select * from TA cross join TB 
--ÏÂÃæµÄÊÇÁíÒ»ÖÖд·¨
select * from TA ,TB 
   1,WANG,100
   2,ZHANG,100
   4,NULL,100
   1,WANG,200
   2,ZHANG,200
   4,NULL,200
   1,WANG,400
   2,ZHANG,400
   4,NULL,400
¼´£ºÒÔ×ó±ßµÄ±íΪ׼£¬Ç°±ßÒ»ÕűíµÄ¼Ç¼·Ö±ðÓëºóÒ»ÕűíµÄÿÌõ¼Ç¼½áºÏ¡£
Èç¹û½«Á½ÕÅ±í·´¹ýÀ´Ð´select * from TB £¬ TA »òÕßselect * from TB cross join  TA
   1,100,WANG
   2,200,WANG
   3,400,WANG
   1,100,ZHANG
   2,200,ZHANG
   3,400,ZHANG
   1,100,LI
   2,200,LI
   3,400,LI
µÑ¿¨¶û»ýµÄ½á¹û¿ÉÄÜ»á²úÉúÖظ´¼Ç¼¡£
TA:
    1,WANG
    2,ZHANG
    3,NULL
   
 TB:
     1,100
     2,200
     3,NULL
     4,NULL
TA*TB
SELECT * from TA,TB B(»òSELECT * from TA CROSS JOIN TB)
1,WANG,100
2,ZHANG,100
3,NULL,100
1,WANG,200
2,ZHANG,200
3,NULL,200
1,WANG,


Ïà¹ØÎĵµ£º

ÔÚSQL SERVERÖÐʵÏÖRSA¼ÓÃÜËã·¨

/***************************************************  
          ×÷Õߣºherowang(ÈÃÄãÍû¼ûÓ°×ÓµÄǽ£©
    ÈÕÆÚ£º2010.1.1
          ×¢£º    ×ªÔØÇë±£Áô´ËÐÅÏ¢
  & ......

phpѧϰ±Ê¼Ç£¨10£©:MYSQLÊý¾Ý¿âÖеij£ÓÃSQLÓï¾ä

MYSQLÊý¾Ý¿âÖеij£ÓÃSQLÓï¾ä
1¡¢SELECT ²éѯÓï¾äºÍÌõ¼þÓï¾ä
SELECT  ²éѯ×ֶΠfrom ±íÃû WHERE Ìõ¼þ 
²éѯ×ֶΣº¿ÉÒÔʹÓÃͨÅä·û* ¡¢×Ö¶ÎÃû¡¢×ֶαðÃû
±íÃû£º Êý¾Ý¿â.±íÃû £¬±íÃû
³£ÓÃÌõ¼þ£º = µÈÓÚ ¡¢<>²»µÈÓÚ¡¢in °üº¬ ¡¢&nb ......

SQL±êʶֵ £¨×ª£©

@@IDENTITY£º·µ»Ø×îºó²åÈëµÄ±êʶֵµÄϵͳº¯Êý¡£
SCOPE_IDENTITY£º·µ»Ø²åÈ뵽ͬһ×÷ÓÃÓòÖеıêʶÁÐÄÚµÄ×îºóÒ»¸ö±êʶֵ¡£Ò»¸ö·¶Î§ÊÇÒ»¸öÄ£¿é£º´æ´¢¹ý³Ì¡¢´¥·¢Æ÷¡¢º¯Êý»òÅú´¦Àí¡£Òò´Ë£¬Èç¹ûÁ½¸öÓï¾ä´¦ÓÚͬһ¸ö´æ´¢¹ý³Ì¡¢º¯Êý»òÅú´¦ÀíÖУ¬ÔòËüÃÇλÓÚÏàͬµÄ×÷ÓÃÓòÖС£
IDENT_CURRENT:·µ»ØΪָ¶¨µÄ±í»òÊÓͼÉú³ÉµÄ×îºóÒ»¸ö±êʶֵ ......

PL/SQL³ÌÐòÉè¼Æ£¨ÓαêµÄʹÓÃ)

ΪÁË´¦Àí SQL Óï¾ä£¬ORACLE ±ØÐë·ÖÅäһƬ½ÐÉÏÏÂÎÄ( context area )µÄÇøÓòÀ´´¦ÀíËù±ØÐèµÄÐÅÏ¢£¬ÆäÖаüÀ¨Òª´¦ÀíµÄÐеÄÊýÄ¿£¬Ò»¸öÖ¸ÏòÓï¾ä±»·ÖÎöÒÔºóµÄ±íʾÐÎʽµÄÖ¸ÕëÒÔ¼°²éѯµÄ»î¶¯¼¯(active set)¡£
 ÓαêÊÇÒ»¸öÖ¸ÏòÉÏÏÂÎĵľä±ú( handle)»òÖ¸Õ롣ͨ¹ýÓα꣬PL/SQL¿ÉÒÔ¿ØÖÆÉÏÏÂÎÄÇøºÍ´¦ÀíÓï¾äʱÉÏÏÂÎÄÇø»á·¢ÉúЩʲôÊÂÇ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ