SELECT ser_id
FROM services
WHERE name = "office_small"
AND pr_id = (
SELECT pr_id
FROM profile
WHERE pr_name like ( SELECT sel_profile
FROM customer
WHERE id =443
)
)
嗨,每一个我在MySQL
中使用上层查询但是它返回零行但是当我在in子句中使用它时它会返回正确的结果,所以如果对内部查询有任何限制使用吗?
感谢
答案 0 :(得分:0)
尝试运行上一次的查询
1.SELECT sel_profile FROM customer WHERE id =443 =OUTPUT
2.(SELECT pr_id FROM profile WHERE pr_name like =OUTPUT) =OUTPUT2
3.(SELECT ser_id FROM services WHERE name = "office_small" AND pr_id = OUTPUT2) =OUTPUT3
如果您得到了正确的结果,那么您就是正确的路径,否则可能会出现与数据库表相关的问题
答案 1 :(得分:0)
1.SELECT sel_profile FROM customer WHERE id =443 =OUTPUT
2.(SELECT pr_id FROM profile WHERE pr_name like '%OUTPUT%') =OUTPUT2
3.(SELECT ser_id FROM services WHERE name = "office_small" AND pr_id = OUTPUT2) =OUTPUT3