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 > PC based Database Applications > Microsoft Access > Correct syntax for inner join on multiple tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-07, 14:46
ozzii ozzii is offline
Registered User
 
Join Date: Mar 2007
Posts: 205
Correct syntax for inner join on multiple tables

Hi,

Can some body tell me what the correct syntax is for an inner join on multiple tables?

I am trying to run the following query in Microsoft Access but it keeps coming up with syntax error.

Code:
SELECT JS.JobseekerID
         , JS.FirstName
         , JS.LastName
         , JS.Currency
         , JS.AccountRegDate
         , JS.LastUpdated
         , JS.NoticePeriod
         , JS.Availability
         , C.CountryName
         , S.SalaryAmount
         , DD.DisciplineName
         , DT.DegreeLevel 
    FROM Jobseekers JS 
INNER 
   JOIN Countries C 
      ON JS.CountryID = C.CountryID 
INNER 
   JOIN SalaryBracket S 
      ON JS.MinSalaryID = S.SalaryID 
INNER 
  JOIN DegreeDisciplines DD 
     ON JS.DegreeDisciplineID = DD.DisciplineID 
INNER 
  JOIN DegreeType DT 
     ON JS.DegreeTypeID = DT.DegreeTypeID 
WHERE
  JS.ShowCV = 'Yes'
Does Access use different sql syntax or something?
Reply With Quote
  #2 (permalink)  
Old 04-19-07, 15:12
RedNeckGeek RedNeckGeek is offline
Village Idiot
 
Join Date: Jul 2003
Location: Michigan
Posts: 1,941
Access likes you to use parantheses for some reason...
Code:
 FROM (((Jobseekers JS 
INNER 
   JOIN Countries C 
      ON JS.CountryID = C.CountryID) 
INNER 
   JOIN SalaryBracket S 
      ON JS.MinSalaryID = S.SalaryID) 
INNER 
  JOIN DegreeDisciplines DD 
     ON JS.DegreeDisciplineID = DD.DisciplineID) 
INNER 
  JOIN DegreeType DT 
     ON JS.DegreeTypeID = DT.DegreeTypeID
I think it's looking for something like that.
__________________
Inspiration Through Fermentation
Reply With Quote
  #3 (permalink)  
Old 04-20-07, 09:53
ozzii ozzii is offline
Registered User
 
Join Date: Mar 2007
Posts: 205
Why do I even need to use the inner join statement in an SQL query when I can acheive the same by using the AND operator as follows:

Code:
SELECT JS.JobseekerID
         , JS.FirstName
         , JS.LastName
         , JS.Currency
         , JS.AccountRegDate
         , JS.LastUpdated
         , JS.NoticePeriod
         , JS.Availability
         , C.CountryName
         , S.SalaryAmount
         , DD.DisciplineName
         , DT.DegreeLevel 
    FROM Jobseekers JS, Countries C, SalaryBracket S, DegreeDisciplines DD
         , DegreeType DT
    WHERE
           JS.CountryID = C.CountryID 
           AND JS.MinSalaryID = S.SalaryID 
           AND JS.DegreeDisciplineID = DD.DisciplineID 
           AND JS.DegreeTypeID = DT.DegreeTypeID 
           AND  JS.ShowCV = 'Yes'
Reply With Quote
  #4 (permalink)  
Old 10-09-09, 05:08
geossl geossl is offline
Registered User
 
Join Date: Apr 2004
Posts: 4
Question What about Cross Join and Left Join together??

how is the syntax if cross Join and left join together....?

such as

select *
FROM Organziation
CROSS JOIN Item
LEFT JOIN (
SELECT *
FROM Event, Program
WHERE Event.ID = Program.EventID
AND Event.Accepted = true
) AS List ON List.OrganizationID = OrganizationID
Reply With Quote
  #5 (permalink)  
Old 10-09-09, 06:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
Quote:
Originally Posted by ozzii
Why do I even need to use the inner join statement in an SQL query when I can acheive the same by using the AND operator as follows:
because JOIN syntax is significantly easier to understand

furthermore, it is a simple matter to turn an INNER JOIN into a LEFT OUTER JOIN when you have to, whereas with the comma-style joins (where the tables are listed in the FROM clause, and the join conditions specified in the WHERE clause), this is quite problematic
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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