I'm working in Access 2007, and I'm a lot more comfortable with SQL than with 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:
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. These address rows have three types:
Also,
I need to get the address information for all the address rows for every 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. So I have one where clause that lists three conditions. 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". You typed "ONL" instead of "ON"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.