我有4个不同的表:
我需要找到居住在重点区域内的患者姓名。
我已设法获取患者居住的邮政编码,以及重点区域内的邮政编码,但我不知道如何加入两个查询:
air.focusarea.objectid = 1
mysqli_insert_id()
因为焦点区域有不同的边界。
有什么想法吗?
谢谢
塔尼亚
答案 0 :(得分:1)
select
a.postcode, p.name
from air.address as a
inner join air.patient as p on
p.address_id = a.address_id
inner join air.postcode as pc on
pc.postcode = a.postcode
inner join air.focusarea as fa on
fa.objectid = 1 and
ST_Intersects(pc.geom, fa.geom);