If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > several outer joins on the same table in access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-28-04, 11:55
deddyh deddyh is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
several outer joins on the same table in access

Hi,
I'm trying to outer join the same table twice ir more like that:

"SELECT author,
co_author_1,
s.bio_url AS au_bio,
s1.bio_url AS co1_bio
FROM articles AS a
LEFT JOIN staff s ON (a.author = s.person_name)
LEFT JOIN staff s1 ON (a.author = s1.person_name)
WHERE article_section='commentary' ORDER BY article_date DESC"

and I get the following error :

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression '(a.author = s.person_name) LEFT JOIN staff s1 ON (a.author = s1.person_name)'.

what os the correct way to do this
thanks
Reply With Quote
  #2 (permalink)  
Old 02-28-04, 12:25
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
you need to parenthesize two tables at a time whenever there are more than two tables in the query:
PHP Code:
select author
     
co_author_1
     
article_date
     
s.bio_url as au_bio
     
s1.bio_url as co1_bio
  from 
(
       
articles as a
left outer
  join staff s 
    on a
.author s.person_name
       
)
left outer
  join staff s1 
    on a
.author s1.person_name
 where article_section 
'commentary' 
order 
    by article_date desc 
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-28-04, 15:24
deddyh deddyh is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
thank u so much!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On