首页 > 如何合并多个查询为一个查询?

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

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个查询?


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)

【热门文章】
【热门文章】