Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Help with 3 table left outer join
Old 08-05-2006, 03:41 AM Help with 3 table left outer join
Average Talker

Posts: 25
Trades: 0
Hi All,

I am trying to retrieve data from 3 tables where the ID field is
common in all 3 tables.

When I write a 2-table left outer join everything works
perfectly:

Code:
strSQL = ("SELECT * FROM tblform LEFT OUTER JOIN tblDiscussion ONtblform.CCF = tblDiscussion.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " ")



When I try to add another table I receive either one of the following errors:

Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression .

OR

Microsoft VBScript compilation (0x800A03EE)
Expected ')'

I have tried several different variations including:

1) Code:
("SELECT * FROM tblform LEFT OUTER JOIN tblDiscussion ONtblform.CCF = tblDiscussion.CCFID LEFT OUTER JOIN tblUpload ONtblform.CCF = tblUpload.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " ")




2) Code:
("SELECT * FROM tblform (LEFT OUTER JOIN tblDiscussion ONtblform.CCF = tblDiscussion.CCFID) LEFT OUTER JOIN tblUpload ONtblform.CCF = tblUpload.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " ")



3) Code:
("SELECT * FROM tblform LEFT OUTER JOIN tblDiscussion ONtblform.CCF = tblDiscussion.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " LEFT OUTER JOIN tblUpload ONtblform.CCF = tblUpload.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " ")



After 4 days I still cannot get this to successfully work.
Any ideas please?
Thanks!
devine is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-05-2006, 05:05 PM Re: Help with 3 table left outer join
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
you need to nest the brackets
Code:
"SELECT * FROM (tblform LEFT OUTER JOIN tblDiscussion ON tblform.CCF = tblDiscussion.CCFID (LEFT OUTER JOIN tblUpload ON tblform.CCF = tblUpload.CCFID WHERE tblform.ccf=" &Request.QueryString("qryID") & " "))
Looks about right I think

you should also cast the querystring parameter into the correct type for the field.

1/ because a querystring value will be a string type and ID fields could be a numeric type.

2/ because using untested querystring values can leave your queries wide open to injection attacks.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Help with 3 table left outer join
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09998 seconds with 12 queries