Thanks for replying. I tried that query but I get the following error:
Query failed : You have an error in your SQL syntax... ... right syntax to use near 'EXISTS ( SELECT * FROM new_products t03 WHERE t03 I think I will have to forget the join, split and do a compare directly in php. Also, I want to get n random unique results from a query, can it be done using sql? Pedro Almeida. -----Mensagem original----- De: Alex S Moore [mailto:[EMAIL PROTECTED] On Wed, 29 Dec 2004 19:57:04 -0000 "mail.pmpa" <[EMAIL PROTECTED]> wrote: > What I am trying to do is: > Select products and join brand, but only products that are not new products. > What I have is: > > ( SELECT products.id, products.model > FROM products, brands > WHERE products.brand = brands.id ) > UNION ALL > ( SELECT products.id, products.model > FROM products, new_products > WHERE products.id != new_products.product_id ) SELECT t01.id, t01.model FROM products t01 JOIN brands t02 ON t01.brand = t02.id WHERE NOT EXISTS ( SELECT * FROM new_products t03 WHERE t03.product_id = t01.id) Alex -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]