【Access】 LEFT OUTER JOIN 关联多表的查询语句
Access 支持三表或三表以上的 JOIN 操作,但是要加括号,一层一层 JOIN 下去。
例如:
SELECT * FROM (aa LEFT JOIN bb ON aa.a = bb.a ) LEFT JOIN cc ONcc.a = bb.a;
这里需要注意一个问题,在使用join语句查询时,也可以加多个条件,不过要用括号括起来,
如:
错误的例子:SELECT * FROM (cc LEFT JOIN aa ON aa.a=cc.a) LEFT JOIN bb ON bb.a=aa.a AND aa.b=bb.b 会报错。
LEFT 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)