Re: how to get records from one table that are not in another table
| From: | John W. Holmes | Date: | Sun, 27 Jul 2003 16:52:42 +0000 |
| Subject: | Re: how to get records from one table that are not in another table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29501@lists.php.net to get a copy of this message | ||
Smita Manohar wrote:
but there is one more criteria, hotel_id from table hotel_room_type_d should be equal to some value.... i modified it like this... SELECT A.room_type_id, room_type_desc FROM room_type_m A LEFT JOIN hotel_room_type_d B ON A.room_type_id = B.room_type_id WHERE B.room_type_id IS NULL AND B.hotel_id = '$hotel_id' is it necessary to select hotel id also, ie. SELECT A.room_type_id, B.hotel_id FROM room_type_m A LEFT JOIN hotel_room_type_d B.....No, you don't have to select that column. Only if you need it.
but one more question ... follwoing query didnt work... SELECT A.room_type_id FROM room_type_m A WHERE A.room_type_id NOT IN(select B.room_type_id from hotel_room_type_d B) im not sure about syntax...This would work if the DB system you're using supported subqueries. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com