Forum Moderators: open

Message Too Old, No Replies

Multiple table join

         

aweise

5:32 pm on Apr 9, 2004 (gmt 0)

10+ Year Member



I'm having trouble with my join syntax. Could anyone help me? I am trying to join three tables with a common field of pubId.

Thanks,

SQL = "SELECT d.id, d.pubTitle, d.pubImage, d.pubFile, d.pubId, d.pubDesc, t.pubType, v.div from pubDetail d, pubType t "&_
"LEFT JOIN pubDiv v ON v.divId = d.divId "&_
" and t.pubId = d.pubId "&_
" where v.divId = " & Request.Querystring("divId") & " " &_
" order by d.pubTitle "

Error Message
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in JOIN operation.

detail_div.asp, line 34

duckhunter

3:47 am on Apr 10, 2004 (gmt 0)

10+ Year Member



Don't think you need the LEFT JOIN but add it back if so.
Since there is only one d.DivID per v.<records> the "where v.divId =" should limit the resultset from the right side.

SELECT d.id, d.pubTitle, d.pubImage, d.pubFile, d.pubId, d.pubDesc, t.pubType, v.div
from pubDetail d
JOIN pubType t ON d.pubId = t.pubId
JOIN pubDiv v ON v.divId = d.divId
where v.divId = Request.Querystring("divId")
order by d.pubTitle