homepage Welcome to WebmasterWorld Guest from 23.22.252.150
register, login, search, subscribe, help, library, PubCon, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library : Charter : Moderators: physics & whoisgregg

Databases Forum

    
FULL JOIN vs JOIN/LEFT JOIN
noyearzero




msg:4043488
 4:24 pm on Dec 15, 2009 (gmt 0)

Hows come this is ok
SELECT * FROM customers LEFT JOIN tickets ON tickets.cstId = customers.cstId

but this returns this error "Unknown column 'customers.cstId' in 'on clause'"
SELECT * FROM customers FULL JOIN tickets ON tickets.cstId = customers.cstId

I've been using left joins for quite a while, but this is the first time i've had to use a full join. i thought it would be just as straight forward.

 

noyearzero




msg:4043625
 7:59 pm on Dec 15, 2009 (gmt 0)

i'm starting to think what i need is a RIGHT JOIN... but whilst messing around i'm becoming even more perplexed

how come the first two queries return different numbers of records. however #3 and #1 match?

1) SELECT * FROM customers LEFT JOIN tickets ON customers.cstId = tickets.cstId

2) SELECT * FROM customers LEFT JOIN (SELECT * FROM tickets) AS tickets ON customers.cstId = tickets.cstId

3) SELECT * FROM customers LEFT JOIN (SELECT * FROM tickets WHERE 1) AS tickets ON customers.cstId = tickets.cstId

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
WebmasterWorld ® and PubCon ® are a Registered Trademarks of Pubcon Inc.
© Pubcon Inc. 1996-2012 all rights reserved