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
three tables with 2 joins
Old 02-04-2008, 12:08 PM three tables with 2 joins
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Hi guys, I am trying to learn more about joins, so this is just a few tables I threw together to learn with. That's why the table names andcolumn names are so simple...

I am trying to pull info from three tables.. I am first trying to get the sql statement to work before moving on to displaying data. This is giving me the following message...

Syntax error (missing operator) in query expression 'a.b_id = b.b_id JOIN c ON b.c_id = c.c_id'.

Here is my code:

Code:
 
<%
strQ = "SELECT a_name, a_id, a.b_id, a.c_id, b.c_id, b.b_name, c.c_name FROM a"
strQ = strQ & " INNER JOIN b"
strQ = strQ & " ON a.b_id = b.b_id"
strQ = strQ & " JOIN c"
strQ = strQ & " ON b.c_id = c.c_id;"
 
objRS.Open strQ
%>
any help is much appreciated...

Thanks,

Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
 
Register now for full access!
Old 02-04-2008, 05:20 PM Re: three tables with 2 joins
Novice Talker

Posts: 5
Trades: 0
it has to be LEFT JOIN, not just JOIN to work...
atlantictech is offline
Reply With Quote
View Public Profile
 
Old 02-05-2008, 01:02 AM Re: three tables with 2 joins
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
The other thing I find works is to put your first join in brackets:
Code:
strQ = "SELECT a_name, a_id, a.b_id, a.c_id, b.c_id, b.b_name, c.c_name FROM (a"
strQ = strQ & " INNER JOIN b"
strQ = strQ & " ON a.b_id = b.b_id)"
strQ = strQ & " INNER JOIN c"
strQ = strQ & " ON b.c_id = c.c_id;"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 02-05-2008, 01:16 PM Re: three tables with 2 joins
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Adam, I tried it and it works!. I am excited...! I am making an honest effort to truly understand as much about asp as I can...

I can do easy stuff but am truly excited about learning some more.

Thanks very much.

I'm also going to try the LEFT JOIN too. I do want to learn as much as I can.

Thanks a lot.

Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 02-06-2008, 05:29 AM Re: three tables with 2 joins
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.w3schools.com/sql/sql_join.asp

JOIN syntax
__________________
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 online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-07-2008, 10:08 AM Re: three tables with 2 joins
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Thanks Chris,

This is great! I'll put w3schools on my favorites...
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 02-07-2008, 11:51 AM Re: three tables with 2 joins
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Good thinking, Chip. W3Schools about the only time you'll ever see the W3 explain things in English as opposed to doublespeak.

Glad the query worked for you, too!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to three tables with 2 joins
 

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.78334 seconds with 12 queries