Welcome to WebmasterWorld Guest from 54.166.152.121

Forum Moderators: open

Message Too Old, No Replies

FULL JOIN vs JOIN/LEFT JOIN

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

5+ Year Member



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)

5+ Year Member



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

 

Featured Threads

Hot Threads This Week

Hot Threads This Month