Re: how to get records from one table that are not in anothertable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux