SQLÊý¾Ý¿âÖ®¶þ
l INNER JOIN
ÄÚÁ¬½ÓÊÇ×î³£¼ûµÄÒ»ÖÖÁ¬½Ó£¬ËüÒ³±»³ÆΪÆÕͨÁ¬½Ó£¬¶øE.FCodd×îÔç³Æ֮Ϊ×ÔÈ»Á¬½Ó¡£
ÏÂÃæÊÇANSI SQL£92±ê×¼
select * from t_institution i
inner join t_teller t
on i.inst_no = t.inst_no //˵Á½¸ö±íÖ®¼äµÄ¹ØϵÓÃON
where i.inst_no = "5801"
ÆäÖÐinner¿ÉÒÔÊ¡ÂÔ¡£µÈ¼ÛÓÚÔçÆÚµÄÁ¬½ÓÓï·¨
select * from t_institution i, t_teller t
where i.inst_no = t.inst_no
and i.inst_no = "5801"
SELECT *
from Ã÷ÈÕ¹¤×ʱí AS a INNER JOIN ²¿Ãűí AS b
ON a.²¿ÃÅÃû³Æ=b.²¿ÃÅÃû³Æ
WHERE ¹¤×ÊÔ·Ý='3'
l LEFT OUTER JOIN---1
select * from t_institution i //±íÔÚfromÖеĶ¨Òå±ðÃû²»ÐèÒªAS
left outer join t_teller t
on i.inst_no = t.inst_no
ÆäÖÐouter¿ÉÒÔÊ¡ÂÔ¡£
SELECT a.²¿ÃűàºÅ,a.²¿ÃÅÃû³Æ,a.¸ºÔðÈË,
b.ÈËÔ±±àºÅ,b.ÈËÔ±ÐÕÃû,b.²¿ÃÅÃû³Æ,
b.ѧÀú,b.¼¼ÊõÖ°³Æ
from Ã÷ÈÕ²¿Ãűí a LEFT OUTER JOIN Ã÷ÈÕÈËÔ±±í b
ON a.²¿ÃÅÃû³Æ=b.²¿ÃÅÃû³Æ
l LEFT OUTER JOIN---2
USE pubs //¶¨ÒåҪʹÓõÄÊý¾Ý¿â
SELECT a.au_fname, a.au_lname, p.pub_name
from authors a LEFT OUTER JOIN publishers p
ON a.city = p.city
ORDER BY p.pub_name ASC, a.au_lname ASC, a.au_fname ASC
l RIGHT OUTER JOIN
select * from t_institution i
right outer join t_teller t
on i.inst_no = t.inst_no
SELECT *
from ²¿Ãűí a RIGHT OUTER JOIN Ã÷ÈÕ¹¤×ʱí b
ON a.²¿ÃÅÃû³Æ=b.²¿ÃÅÃû³Æ
WHERE b.¹¤×ÊÔ·Ý='10'
l FULL OUTER
È«ÍâÁ¬½Ó·µ»Ø²ÎÓëÁ¬½ÓµÄÁ½¸öÊý¾Ý¼¯ºÏÖеÄÈ«²¿Êý¾Ý£¬ÎÞÂÛËüÃÇÊÇ·ñ¾ßÓÐÓëÖ®ÏàÆ¥ÅäµÄÐС£ÔÚ¹¦ÄÜÉÏ£¬ËüµÈ¼ÛÓÚ¶ÔÕâÁ½¸öÊý¾Ý¼¯
Ïà¹ØÎĵµ£º
1.Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)¡¡¡¡
¡¡¡¡ SQLSERVERµÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬Òò´Ëfrom×Ó¾äÖÐдÔÚ×îºóµÄ±í£¨»ù´¡±ídriving table£©½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í£¬µ±SQLSERVER´¦Àí¶à¸ö±íʱ£¬»áÔËÓÃÅÅÐò¼°ºÏ²¢µÄ·½Ê½Á ......
Èç¹ûÄã¾³£Óöµ½ÏÂÃæµÄÎÊÌ⣬Äã¾ÍÒª¿¼ÂÇʹÓÃSQL ServerµÄÄ£°åÀ´Ð´¹æ·¶µÄSQLÓï¾äÁË£º
SQL³õѧÕß¡£
¾³£Íü¼Ç³£ÓõÄDML»òÊÇDDL SQL Óï¾ä¡£
ÔÚ¶àÈË¿ª·¢Î¬»¤µÄSQLÖУ¬Ã¿¸öÈ˶¼ÓÐ×Ô¼ºµÄSQLÏ°¹ß£¬Ã»ÓÐÒ»Ì×ͳһµÄ¹æ·¶¡£
ÔÚSQL Server Management StudioÖУ¬ÒѾ¸ø´ó¼ÒÌṩÁ˺ܶೣÓõÄÏÖ³ÉSQL¹æ·¶Ä£°å¡£
SQL Server Management ......
·½·¨Ò»¡¢¾¡Á¿Ê¹Óø´ÔÓµÄSQLÀ´´úÌæ¼òµ¥µÄÒ»¶Ñ SQL.
ͬÑùµÄÊÂÎñ£¬Ò»¸ö¸´ÔÓµÄSQLÍê³ÉµÄЧÂʸßÓÚÒ»¶Ñ¼òµ¥SQLÍê³ÉµÄЧÂÊ¡£Óжà¸ö²éѯʱ£¬ÒªÉÆÓÚʹÓÃJOIN¡£
oRs=oConn.Execute("SELECT * from Books")
while not oRs.Eof
strSQL = "SELECT * from Authors WHERE AuthorID="&oRs("AuthorID") oRs2=oConn.Execute(strSQ ......
ÎÊÌâ
¡¡¡¡µ±sql serverÆô¶¯Ê±£¬ÎÒºÜÏëÔËÐÐÒ»¸ö´æ´¢¹ý³Ì¡£ÓÐûÓÐÒ»ÖÖ·½·¨¿ÉÒÔÔÚÿ´ÎSQL Server·þÎñÆô¶¯Ê±¶¼»á×Ô¶¯Ö´ÐÐÕâ¸ö´æ´¢¹ý³ÌÄØ?
¡¡¡¡×¨¼Ò½â´ð
¡¡¡¡sql ServerÌṩÁËϵͳ´æ´¢¹ý³Ìsp_procoption£¬Õâ¸ö´æ´¢¹ý³Ì¿ÉÒÔÓÃÓÚµ±SQL Server·þÎñÆô¶¯Ê±Ö¸ÅÉÒ»¸ö»òÕ߶à¸ö´æ´¢¹ý³Ì×Ô¶¯Ö´ÐС£ÕâÊÇÒ»¸öºÜ²»´íµÄÑ¡Ôñ£¬Ëü¿ÉÒÔÓÃÓÚ¶àÖÖ ......