在Access 2007中应如何编写带有左联接的SQL? [英] How Should This SQL with Left Joins be Written in Access 2007?

查看:53
本文介绍了在Access 2007中应如何编写带有左联接的SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条带有多个左联接的sql语句,消息说我无法在Access 2007中工作,

I have a sql statement with multiple left joins that I cannot get to work in Access 2007, the message stating,

不支持JOIN表达式

JOIN expression not supported

SELECT
  Foo.A,
  Bar.B,
  Baz.C,
  Bat.D
FROM
  Foo
LEFT JOIN
  Bar ON Foo.BarId = Bar.BarId
LEFT JOIN
  Baz ON Foo.BazId = Baz.BazId
LEFT JOIN
  Bat ON Foo.BatId = Bat.BatId

WHERE 
  Foo.CriteriaColumn = 1

Access 2007的正确格式是什么?

What is the correct format for Access 2007?

推荐答案

自从我在Access中加入联接已经有一段时间了,但是将每个联接表达式单独括在括号中应该可以解决问题:

It's been a while since I did joins in Access, but enclosing each join expression separately in parentheses should do the trick:

SELECT
  Foo.A,
  Bar.B,
  Baz.C,
  Bat.D
FROM
  ((Foo
LEFT JOIN
  Bar ON Foo.BarId = Bar.BarId)
LEFT JOIN
  Baz ON Foo.BazId = Baz.BazId)
LEFT JOIN
  Bat ON Foo.BatId = Bat.BatId
WHERE 
  Foo.CriteriaColumn = 1

这篇关于在Access 2007中应如何编写带有左联接的SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆