Database °æ (¾«»ªÇø)
·¢ÐÅÈË: sleep (ÐÝÏ¢ÐÝÏ¢), ÐÅÇø: Database
±ê Ìâ: Éè·¨½«Ò»¸ö±íÓë¶à¸ö±í½¨Á¢×óÁª½ÓÖÐÒ»¸öÈÝÒײúÉúµÄ´íÎ
·¢ÐÅÕ¾: ¹þ¹¤´ó×϶¡Ïã (2000Äê12ÔÂ04ÈÕ14:29:38 ÐÇÆÚÒ»), Õ¾ÄÚÐżþ
ʹÓà SQL£¬ÎÒÕýÔÚÉè·¨½«Ò»¸ö±íÓë¶à¸ö±í½¨Á¢×óÁª½Ó¡£µ±²éѯÐèÒªµÄËùÓбí´ò¿ªÊ±£¬¸Ã
²éѯ¿ÉÒÔ¹¤×÷¡£µ«Êǵ±ÓÐЩ±íûÓдò¿ªÊ±£¬¾Í»á²úÉú´íÎ󡣶øÇÒµ±ËùÓбí´ò¿ªÊ±£¬¾¡¹Ü
ûÓвúÉú´íÎóÐÅÏ¢£¬µ«½á¹û²»ÕýÈ·¡£ÎªÊ²Ã´£¿
´ð°¸£º µ±ÊÔͼ½¨Á¢Ò»¸ö±í¶Ô¶à¸ö±íµÄ×óÁª½Óʱ£¬ÄúÒ²ÐíʹÓÃÁËÏÂÃæÓï¾ä£¬¸ÃÓï¾äÓñí
±ðÃû½øÐÐÁË¡°×ÔÁª½Ó¡±¡£ÄúµÄ SQL Óï¾ä¿ÉÄÜÈçÏÂËùʾ£º
select one.firstname as first, one.lastname as second,;
two.firstname as third, two.lastname as fourth;
from FirstTable;
left outer join SecondTable one;
left outer join SecondTable two;
left outer join ThirdTable;
on ThirdTable.ThirdID=FirstTable.FirstID
on Two.SecondID=FirstTable.FirstID
on one.SecondID=FirstTable.FirstID
order by 4,3,2,1
ÕâÀïµÄ²éѯÊÔͼ½«ÁÙʱ±í One¡¢Two ÒÔ¼° ThirdTable ×óÁª½Óµ½ FirstTable ÉÏ£
µ«ÊÇûÓеõ½Ô¤ÆÚµÄЧ¹û¡£²éѯ·ÖÎöÆ÷´Ó×îÀïÃæµÄÁª½Ó¿ªÊ¼·ÖÎö²éѯ£¨ÔÚÉÏÃæÓï
¾äÖÐΪ "left outer join ThirdTable"£©£¬µ«ÊDz»Äܶ¨Î» FirstTable
±í£¬¸Ã±íÃû×ÖλÓÚ´ËÓï¾äµÄÉÏÃæ¡£Òò´Ë£¬Èç¹ûûÓдò¿ª±í£¬Äú¾Í»á·¢ÏÖ´íÎó£¬Èç
"SQL: Column 'ThirdID' ûÓÐÕÒµ½"£¬Í¬Ê±Êä³öÒ²²»ÕýÈ·¡£
µ±±í´ò¿ªÊ±£¬"couple.coupleid" °ó¶¨µ½Íⲿ£¨·ÇSQL£©ÁÙʱ±í "couple" µÄ×Ö¶ÎÉÏ¡£
´Ë²éѯҲÊǺϷ¨µÄ£¬µ«Êǵò»µ½Ô¤ÆÚµÄЧ¹û¡£ÎªÁ˱ÜÃâ´Ë´íÎ󣬲¢Äܹ»µÃµ½ÕýÈ·½á¹û£¬
¿ÉÒÔʹÓÃÀàËÆÈçÏ嵀 SQL Óï¾ä£º
select one.firstname as first, one.lastname as second,;
two.firstname as third, two.lastname as fourth;
from (((FirstTable;
left outer join SecondTable One;
on one.SecondID = FirstTable.FirstID);
left outer join SecondTable Two;
on Two.SecondID = FirstTable.FirstID);
left outer join ThirdTable;
on ThirdTable.ThirdID = FirstTable.FirstID);
order by 4,3,2,1
Óï¾äÖеÄÀ¨ºÅ²»ÊDZØÐëµÄ£¬µ«ÍƼöÄú¼ÓÉÏËü¡£Í¨¹ýÈçÉϵÄÓï¾ä½á¹¹£¬Èç¹ûËùÓеıíÈ«²¿
Êǹرյģ¬Ò²²»»á³ö´í£¬½á¹ûÒ²ÊÇÕýÈ·µÄ¡£
--
¡ù À´Ô´:¡¤¹þ¹¤´ó×϶¡Ïã bbs.hit.edu.cn¡¤[FROM: 202.118.227.121]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
Ò³ÃæÖ´ÐÐʱ¼ä£º2.204ºÁÃë