Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 whats wrong with this SQL?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 16 December 2004 :  15:04:31  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message

	strSQL = "SELECT N.SITE_ID, N.SITE_NAME, C.CAT_ID, C.CAT_TITLE, PAGE_ID, PAGE_TITLE" & _
		 "  FROM SITE_NAME N LEFT JOIN W_CAT C ON C.SITE_ID = P.SITE_ID LEFT JOIN W_PAGE P ON C.CAT_ID = P.CAT_ID" & _
		 " ORDER BY N.SITE_NAME ASC, C.CAT_TITLE, P.PAGE_TITLE"


I get a syntax error when I try running it... I dont know crap about joins, so I dont know where the error is originating.

davemaxwell supplied the code for me.

-Stim

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 16 December 2004 :  17:33:15  Show Profile  Visit D3mon's Homepage
this MS ACCESS or MS SQL SERVER?


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 16 December 2004 :  17:56:32  Show Profile  Visit HuwR's Homepage
it could be getting confused because you are not referencing page_id or page_tile using the P. alias
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 16 December 2004 :  19:08:27  Show Profile  Visit Gremlin's Homepage
I might be going blind, but where is the P alias actually being defined .. I see N (SITE_NAME N) but no P.

scratch that, I am blind .. its in the JOIN clause though something doesn't look right but I can't quite put my finger on it.

Kiwihosting.Net - The Forum Hosting Specialists

Edited by - Gremlin on 16 December 2004 19:10:11
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 16 December 2004 :  20:07:07  Show Profile  Send ruirib a Yahoo! Message
It has several errors:

1. You're joining SITE_NAME N and W_CAT C using a field from C and another from P, instead of another from N;
2. You will need to use parenthesis, since you're using two joins:

FROM ((SITE_NAME N LEFT JOIN W_CAT C ON C.SITE_ID = N(?).SITE_ID) LEFT JOIN W_PAGE P ON C.CAT_ID = P.CAT_ID)



Snitz 3.4 Readme | Like the support? Support Snitz too

Edited by - ruirib on 16 December 2004 20:08:03
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 17 December 2004 :  09:40:53  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
perfect, thx rurib, that worked (I had to remove the (?) though, what was that for?)

Now all I gotta do is process the data correctly

-Stim
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 20 December 2004 :  05:06:46  Show Profile  Send pdrg a Yahoo! Message
D_S - I think the (?) was ruirib guessing at the correct table alias to join to - it was not a part of the SQL!
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 20 December 2004 :  06:51:47  Show Profile  Send ruirib a Yahoo! Message
quote:
Originally posted by pdrg

D_S - I think the (?) was ruirib guessing at the correct table alias to join to - it was not a part of the SQL!

Indeed, that was the reason for the (?).


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.24 seconds. Powered By: Snitz Forums 2000 Version 3.4.07