这是我的SQL查询:
select count(*) from district
但我想只选择存储表资产中至少有1个值的所有区域。 (可以超过1)
所以
select all districts that have at least 1 entry in assets
表资产: id name district_id
表区 id名称
我该怎么做?
答案 0 :(得分:1)
select count(*)
from district
where exists (
select 1
from assets
where district_id = district.id
)