如何合并多个查询为一个查询?

Tevoo
  • 113
select * from table_a where field_a = 1 LIMIT 0, 3;
select * from table_a where field_a = 2 LIMIT 0, 3;
select * from table_a where field_a = 3 LIMIT 0, 3;

如何合并以上3个SQL查询为1个查询?

回复
阅读 4.7k
2 个回答
sqlselect * from table_a where field_a = 1 LIMIT 0, 3
union
select * from table_a where field_a = 2 LIMIT 0, 3
union
select * from table_a where field_a = 3 LIMIT 0, 3;

SELECT * FROM table_a WHERE field_a IN (1, 2, 3)

宣传栏