我有这个问题:
SELECT * from t1
WHERE child_id IN (SELECT child_id from t2 WHERE parent_id='1234')
OR parent_id='1234'
可以做这样的事情:
SELECT * from t1
WHERE child_id IN (
(SELECT child_id from t2 WHERE parent_id='1234')
UNION '5678'
)
UNION
关键字会显示错误消息,我尝试在google上搜索但是当您搜索“Mysql concat IN”时很难找到某些内容
我希望我的问题很清楚
答案 0 :(得分:3)
是的,就像这样:
SELECT * from t1
WHERE child_id IN
(
SELECT child_id from t2 WHERE parent_id='1234'
UNION
SELECT 5678
)
答案 1 :(得分:1)
查询不同(我的意思是示例和带错误的示例),但您可以这样做:
SELECT * from t1
WHERE child_id IN (SELECT child_id from t2 WHERE parent_id='1234'
union all
select '5678'
);