[英]MS Access 2007 syntax: From Join Join Join Where
I'm working in Access 2007, and I'm a lot more comfortable with SQL than with Access. 我在Access 2007中工作,与SQL相比,与Access相比,我更加满意。 After reading several threads on this site related to joins in MS Access, I think I"m doing this correctly, but I am being told I have a syntax error on my where clause. Here is the new, improved? version:
在阅读了该站点上与MS Access中的联接相关的多个线程之后,我认为我做得正确,但是被告知我where子句中出现语法错误。这是经过改进的新版本:
FROM (( Patron P
INNER JOIN Patron_Address PA1 ON
(PA1.patron_id = P.patron_id)
LEFT JOIN Patron_Address PA2 ON
(PA2.patron_id = P.patron_id)
LEFT JOIN Patron_Address PA3 ONL
(PA3.patron_id = P.patron_id)
where PA1.address_type = '1'AND
PA2.address_type = '2' AND
PA3.address_type = '3';
Let me explain my goal. 让我解释一下我的目标。 patron tuples have 1-3 patron_address tuples.
patron元组有1-3个patron_address元组。 These address rows have three types:
这些地址行具有三种类型:
Also, 也,
I need to get the address information for all the address rows for every patron_id. 我需要获取每个patron_id的所有地址行的地址信息。 The data from each address row needs to go into columns in a lare query result set that I then need to turn into a tab-delimited file to send to a vendor.
来自每个地址行的数据都需要进入一个稀疏查询结果集中的列,然后我需要将其转换成制表符分隔的文件以发送给供应商。
This is why I am doing a join and this is why I need to use criteria. 这就是为什么我要进行联接,这就是为什么我需要使用条件。 Logically, the result of each join should have its own where clause, but that's apparently not allowed.
从逻辑上讲,每个联接的结果都应该有自己的where子句,但这显然是不允许的。 So I have one where clause that lists three conditions.
因此,我有一个where子句,其中列出了三个条件。 The problem there is that only one of the three conditions applies to each join.
那里的问题是三个条件中只有一个适用于每个联接。
So what do I need to do conceptually and syntactically to get the result I want? 那么,我需要在概念上和语法上做什么才能获得想要的结果? Thanks for help with this monster the last few days.
感谢最近几天对这个怪物的帮助。 I'm getting close, I think.
我想我正在接近。 Then again, I may have simply moved my error.
再说一次,我可能只是简单地移动了我的错误。
Can you please try the below query:- 您能否尝试以下查询:-
FROM Patron P
INNER JOIN Patron_Address PA1 ON PA1.patron_id = P.patron_id)
LEFT JOIN Patron_Address PA2 ON PA2.patron_id = P.patron_id
LEFT JOIN Patron_Address PA3 ON PA3.patron_id = P.patron_id
where PA1.address_type = '1'
AND PA2.address_type = '2'
AND PA3.address_type = '3';
Technically, I have removed all the brackets and the letter "L" on the last "ON". 从技术上讲,我删除了所有括号和最后一个“ ON”上的字母“ L”。 You typed "ONL" instead of "ON"
您键入“ ONL”而不是“ ON”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.