Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图弄清楚如何根据 id 列从表中选择多行。像这样的东西:
select * from table where id=1 or id=2 or id=3
我应该遍历每个 id 并为每次迭代执行查询吗?
select * from table where id in (1, 2, 3)
如果你想得到 results whereid = 1和 results whereid = 2和 results where id = 3,你必须使用不同的逻辑。
id = 1
id = 2
id = 3
你实际上想要的结果在哪里id = 1 or id = 2 or id = 3
id = 1 or id = 2 or id = 3
或者你想要结果id in (1, 2, 3)
id in (1, 2, 3)
或者你想要结果id between 1 and 3
id between 1 and 3