| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|FULL JOIN vs JOIN/LEFT JOIN|
| 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.
| 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
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved