On Wed, 2002-02-20 at 15:03, ACEAlex wrote: > Hi i have trouble with this mysql query. > > OK, i have 3 different tables. > > Tabel 1: building_info > id > name > price > and other > table 2:queue > id > building_id > table 3:buildings_built > building_id > > Ok, now i want to make a query that gets the data from building_info where > it is not pressent in the queue and the buildings_built table. > > I have managed to get this to work with only 2 tables. So that i can get the > things that are not present in the building_queue or in the buildings_built > > Anyony have a nice solution for this?
If I understood right, something like SELECT A.id,A.name,A.price FROM building_info AS A, queue AS B, buildings_built AS C WHERE (A.id != B.id AND B.building_id = C.building_id) should do it. I tested it on a simple db building_info("1","foo","200") building_info("2","bar","200") queue("1","1") buildings_built("1") This is what I got: mysql> SELECT A.id,A.name,A.price FROM building_info AS A, queue AS B, buildings_built AS C WHERE (A.id != B.id AND B.building_id = C.building_id)\G *************************** 1. row *************************** id: 2 name: bar price: 200 1 row in set (0.00 sec) mysql> Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library [EMAIL PROTECTED] +358-6-325 3589 / +358-40-832 6709 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php