像MySQL中的内部查询的运算符不起作用

时间:2014-03-13 08:25:58

标签: mysql

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子句中使用它时它会返回正确的结果,所以如果对内部查询有任何限制使用吗? 感谢

2 个答案:

答案 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