mysql - How to write the following SQL query? -
mysql - How to write the following SQL query? -
property_for_rent (pno, street, area, city, pcode, type, rooms, rent, ono, sno, bno) owner (ono, fname, lname, address, tel_no)
find name , address of property owners have houses registered rental agency.
there 2 types of property(houses,flat ). "only" have no ideal
select fname, lname, address owner ono in ( select ono property_for_rent type = "house" , ono not in ( select ono property_for_rent type <> "house" ) )
this way, tried. there improve way?
you can in several ways. 1 way utilize group by
, having
. method utilize not exists
:
select o.* owner o not exists (select 1 property_for_rent pfr o.ono = pfr.ono , type <> 'house');
mysql sql
Comments
Post a Comment