请更正以下的sql查询。 这里的列是动态的。 所以我只需要用户*。 查询:
SELECT * FROM test_table WHERE Id IN ('abc','123') GROUP BY Id HAVING COUNT(*) > 1
答案 0 :(得分:0)
如果要选择与所选ID对应的所有列:
select *
from test_table
where id in (
select id
from test_table
where Id in ('abc','123')
group by Id
having COUNT(*) > 1
)
仅限Id:
select id
from test_table
where Id in ('abc','123')
group by Id
having COUNT(*) > 1