-2
CARS(CCODE,ADDRESS,CITY,COLOR)
CARS_CONTRACT(CON_CODE,ST_dATE,END_dATE,PNAME,MONTHLYPRICE,CCODE)
發現CCODE和地址與城市=「新約克」的這montlyprice已經馬麗娟超過500 EVRO以及其中超過7個合同已簽訂,所以我代碼是都不在了,在和「=」操作符SQL
我的代碼..
select ccode,address
from cars c,cars_contract cd
where c.ccode=cd.ccode and city='new-york'
and ccode not in(select ccode from cars_contract where monthlyprice<500
group by ccode,address
having count(*)>7
我的問題是我可以用
這
替換上面的代碼3210select ccode,address
from cars c,cars_contract cd
where c.ccode=cd.ccode and city='new-york'
and monthlyprice>500
group by ccode,address
having count(*)>7
還是這個? (具體我一定要指定內部條款加入條件?)
select ccode,address
from cars c,cars_contract cd
where c.ccode=cd.ccode and city='new-york'
and ccode in(select ccode from cars_contract where monthlyprice>500)
group by ccode,address
having count(*)>7
MySQL或Oracle? –
避免不建議使用的語法,使用明確的'JOIN'和'ON'。除此之外,它取決於您是否希望將篩選應用於子查詢。 –
問題不明確。你能提供樣本輸入和輸出嗎?另外,如已經問過的,請指出這是MySQL還是Oracle。 –