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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -