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 it to a RIGHT JOIN, it will do it last, which is what I think you are looking for. The LEFT and RIGHT join syntax are exactly the same.

On Feb 9, 2004, at 3:47 PM, 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 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 table and another key from another table
combined.
http://www.mysql.com/doc/en/JOIN.html


SELECT
FROM
        t1,
INNER JOIN t2 on (c1)
INNER JOIN t3 on (c2)
LEFT JOIN t4 on (c1,c2)

Thanks!

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to