Hi, You need to use UNION, but it's not possible in version 3.23.* So it's better to upgrade MySQL server first.
SELECT table1.cod FROM table1 LEFT JOIN table4 ON table1.cod=table4.cod WHERE table4.cod IS NULL UNION SELECT table2.cod FROM table2 LEFT JOIN table4 ON table2.cod=table4.cod WHERE table4.cod IS NULL UNION SELECT table3.cod FROM table3 LEFT JOIN table4 ON table3.cod=table4.cod WHERE table4.cod IS NULL Best regards, Mikhail. ----- Original Message ----- From: "ΝΙΚΟΣ ΓΑΤΣΗΣ" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: "Brent Baisley" <[EMAIL PROTECTED]> Sent: Monday, September 15, 2003 1:15 PM Subject: Re: joining 4 tables Thank you all for replying. Brent your code is nice but I'ts not what I want. In "where" clause the equality is not true because its table has diferent cod fields anyway. Can you help me with that? ----- Original Message ----- From: "Brent Baisley" <[EMAIL PROTECTED]> To: <$B&-&)&*&/&2 (B $B&#&!&3&2&'&2(B <[EMAIL PROTECTED]>)> Cc: <[EMAIL PROTECTED]> Sent: Friday, September 12, 2003 3:43 PM Subject: Re: joining 4 tables > SELECT table4.cod, table1.cod, table2.cod, table3.cod > FROM table4 > LEFT JOIN table1 ON table4.cod=table1.cod > LEFT JOIN table1 ON table4.cod=table2.cod > LEFT JOIN table1 ON table4.cod=table3.cod > WHERE table1.cod IS NULL > AND table2.cod IS NULL > AND table3.cod IS NULL > > I think that should do it, I didn't test it. What you are doing is a > left join for all the tables on table4. The left join will retain all > the records of table4, and then you filter out any records that have no > value in the fields for the other tables. > > On Friday, September 12, 2003, at 04:37 AM, $B&-&)&*&/&2(B $B&#&!&3&2&'&2(B wrote: > > > Hello list > > > > I have a problem. I have 4 tables (in Mysql 3.23). All of them have a > > filed > > named cod. > > > > I want a query to find which cod of table1, table2, table3 is/are not > > in > > table4. > > cod values in table1, table2, table3 are diferent. > > > > Thank you > > Nikos > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: > > http://lists.mysql.com/[EMAIL PROTECTED] > > > > > -- > 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]