我无法合并此查询,但如果单独执行两者都可以正常工作。
select name
from zone
where id IN (select proj_tbl_id from project where proj_name = '$project2')
第二次查询的结果
select proj_tbl_id from project where proj_name = '$project2') = (13,14)
如果运行如下,结果为真。
select name from zone where id IN (13,14)
答案 0 :(得分:0)
您可以使用exists
运算符:
SELECT name
FROM zone z
WHERE EXISTS (SELECT *
FROM project p
WHERE z.id = p.proj_tbl_id AND
proj_name = '$project2')