On Wed, 2002-07-31 at 12:03, Luis Rodrigues wrote: > hi, > I have some sql code that I need to use with mysql > it uses nested queries and since mysql doesn't implement them > I would like to know how to do this. > > SELECT * FROM apartamentos > WHERE vendido=0 > AND Concelho=$row["ConcelhoP"] > AND Localidade LIKE '&$row["LocalidadeP"]&' ... > > WHERE Referencia NOT IN ( SELECT Referencia FROM historico_clientes WHERE > NumCliente=$id) > <snip>
It will require something like: SELECT a.* FROM apartamentos a LEFT JOIN historico_clientes h ON a.Referencia = h.Referencia AND h.NumCliente=$id WHERE h.Referencia IS NULL AND vendido=0 AND Concelho=$row["ConcelhoP"] AND Localidade LIKE '&$row["LocalidadeP"]&' ... == Martin --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php