萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> access教程 >> access基礎教程 >> access數據庫多表聯合查詢(Left Join等)的sql語句寫法

access數據庫多表聯合查詢(Left Join等)的sql語句寫法

又一次遇到了這個問題。Access裡執行left join聯合查詢,總是提示:至少一個參數未指定的錯誤,突然想起來access中多表聯合查詢的sql語句比較變態,就抄來高手的文章備忘,希望對和我一樣的苦逼程序員有所幫助。

首先,每次聯合查詢都需要用圓括號括起來:

SELECT * FROM (aa LEFT JOIN bb ON aa.a = bb.a ) LEFT JOIN cc ONcc.a = bb.a;

注意:在使用join語句查詢時,如果有加多個On條件,必須用括號括起來,如:

SELECT * FROM (aa LEFT JOIN bb ON aa.a=bb.a) LEFT JOIN cc ON(bb.a=cc.a and bb.b=cc.b) 

其他例子可以參考:

1、SELECT * FROM URL as a LEFT OUTER JOIN MobileAfter as b ON a.URL = b.URL

2、SELECT * FROM (URL as a LEFT OUTER JOIN MobileAfter as b ON a.URL= b.URL) LEFT OUTER JOIN MobileBefore as c ONc.URL=a.URL

3、SELECT * INTO Ttable1 FROM ((((URL as a

LEFT OUTER JOIN MobileAfter as b ON a.URL=b.URL) 

LEFT OUTER JOIN MobileBefore as c ON c.URL=a.URL) 

LEFT OUTER JOIN TeleCOM as d ON d.URL=a.URL) 

LEFT OUTER JOIN UniCOM as e ON e.URL=a.URL)

關鍵詞:SQL  查詢  多表  聯合 

copyright © 萬盛學電腦網 all rights reserved