Access几个小技巧总结

阅读更多
1、查询Access中的表名称
select name from MSysObjects where type=1 and flags=0 MSysObjects

2、几个查询结果Union All时,当使用了无表查询时,提示“查询输入必须包含至少一个表或查询”
  也就是说在Access里,这样的查询,并不能出想要的结果
  select 'wallimn'
    union all
    select name from MSysObjects

  这时可以建一个一行一列的表,比如效仿Oracle,建一个DUAL,从这个表里查些不相干的东西就行了。
  select 'wallimn' from dual
    union all
    select name from MSysObjects

3、Access多表外联查询(三个或以上)的写法

SELECT * FROM (aa LEFT JOIN bb ON aa.a = bb.a ) LEFT JOIN cc ON cc.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)

你可能感兴趣的:(access)