LEFT JOIN to a table using 2 keys from different tables

2004-02-09 Thread David Perron
Is there a way to do this? Im trying to LEFT JOIN to a table that needs to select based on 2 keys, but the query Im writing only has the keys individually in two separate tables, like this. The documentation shows how to do this when you are using 2 keys from both tables, but not 1 key from 1

Re: LEFT JOIN to a table using 2 keys from different tables

2004-02-09 Thread Jack McKinney
Not sure if this is what you are asking, but how about: SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c2 Big Brother tells me that David Perron wrote: Is there a way to do this? Im trying to LEFT JOIN to a table that needs to select based on 2 keys, but the query Im writing only has the

Re: LEFT JOIN to a table using 2 keys from different tables

2004-02-09 Thread Brent Baisley
It's tough to answer your question without seeing your actual table structure. You can use AND in a join: SELECT * FROM a1 LEFT JOIN b1 ON a1.f1=b1.f1 AND a1.f2=b1.f2 In you example query, MySQL will try to do the LEFT JOIN first (I'm pretty sure), which is not what you what. But if you change