homepage Welcome to WebmasterWorld Guest from 54.166.95.146
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved