[問題] SQL JOIN USING 相關問題

作者: memexo (猴吱吱)   2014-03-21 18:03:22
SELECT ACT_S, /*Q : 為什麼有些欄位不須指定table前置詞,
ex:PD.ACT_S,若是加上前置詞,
會拋錯"PD.ACT_S": invaild identifier*/
PD.ACT_N, /*Q : 又有些欄位一定要加上特定table的前置詞,
ex:AD_N,就會拋錯"column ambiguously defined"*/
COST,
PD.OG_S,
OL_S,
OG.OG_NO
FROM OG
LEFT JOIN OL
USING(OG_S)
LEFT JOIN PD
USING(OL_S)
LEFT JOIN AD
USING(ACT_S)
WHERE PD.OG_S = '20140320A'
AND OG_NO = '20130320B'
AND OL_S = '20140320C'
/*Q: 使用USING()來JOIN table順序上是不是有甚麼特別要求?
ex上例 :
FROM OG FROM OG
LEFT JOIN OL

Links booklink

Contact Us: admin [ a t ] ucptt.com