我遇到这样的情况
Select *
from user_post
where user_id in (select user_id from follow where follow_id=20)
此查询工作正常,我还需要在 where 条件中添加 follow_id 20...选定的 user_id 加上此用户 20 也包含在 WHERE IN 条件中
我尝试过这样
Select *
from user_post
where user_id in (select user_id from follow where follow_id=20) AND user_id=20
它没有带来正确的结果
查询应该是这样的
Select *
from user_post
where user_id in (10,15,20)
如何做到这一点
最佳答案
SELECT
*
FROM
user_post
WHERE
user_id IN ((SELECT
follow_id
FROM
follow
WHERE
follow_id=20), 10, 15);
关于mysql - SQL 查询Where IN 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30175983/