来自子查询的where子句中的Sql多个值

时间:2017-06-02 10:59:03

标签: sql where

基本上,我要做的是:我想要一个sql查询,它返回id为的表中的所有行(一些子查询返回20个ID)。

就像那样:

SELECT * FROM People WHERE People.ID = (SELECT CreatedBy.PeopleID FROM CreatedBy)

3 个答案:

答案 0 :(得分:1)

SELECT * FROM People WHERE People.ID in (SELECT CreatedBy.PeopleID FROM CreatedBy)

答案 1 :(得分:0)

使用'IN'而不是'='

SELECT * FROM People WHERE People.ID IN (SELECT CreatedBy.PeopleID FROM CreatedBy)

答案 2 :(得分:0)

使用而不是=

SELECT * FROM People WHERE People.ID in (SELECT CreatedBy.PeopleID FROM CreatedBy)