I have done this numerous times. What you have to do is match 2 conditions 
in your ON clause.

I need to make up some information to answer your question because I don't 
know all of the table names involved in this particular query (you didn't 
say in your original post). I know you have two tables, customer and 
furnisher, but you seem to have some other table that contains the column 
rif_CF so I will call it "rif".

SELECT ...(some columns)
FROM rif
LEFT JOIN customer c
        ON c.customer_id = rif.ID_CF
        AND rif.rif_CF='C'
LEFT JOIN furnisher f
        ON f.furnisher_ID = rif.ID_CF
        AND rif.rif_CF = 'F'
WHERE NOT (c.customer_ID is null AND f.furnisher_id is null) AND ...


I used qualified names on all of the fields I used. I know your fields are 
probably uniquely named but I prefer this convention for consistency when 
joining tables. I used a LEFT JOIN so that you could get results from 
either "customer" or "furnisher" even if both tables didn't match a row in 
"rif". The first condition in the WHERE clause makes sure you had at least 
one match of either table (which may not be an issue with your data but I 
can't know that without more info from you). 

Let me know if this answers your question. If not, come back to the list 
and explain what you really want and I am sure that someone here can help.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


Wakan <[EMAIL PROTECTED]> wrote on 01/12/2005 09:27:40 AM:

> HI,
> I've 2 fields in a select query rif_CF, ID_CF...
> the rif_CF value (C or F) indicate the meaning of the ID_CF...
> IF rif_CF=C then the ID_CF is a customer ID, IF rif_CF=F the ID_CF is a 
> furnisher ID.
> 
> How can I join 2 tables (customer, and furnisher) in a query?
> 
> SELECT ID_doc, data_doc, rif_CF, ID_CF.....!?!?!?
> thanks
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to