mysql使用union语句保持查询位置-mysql

mysql使用union语句保持查询位置-mysql,mysql,Mysql,至少在我的工作台中,这个伪代码会返回我需要的确切结果。我没有在结尾使用orderby关键字,我总是这样做,因为应用会明显破坏订单 是否有办法确保查询将按以下顺序返回数据?对我来说,我可以通过1,2,3“分区”来修复顺序,而不是将其应用于过高的值,这一点非常重要。我希望你能理解 欢迎提出任何想法。您应该能够添加一个字段来实现此目的,例如: 1. select something, date_something from my_table where [conditions] union 2. se

至少在我的工作台中,这个伪代码会返回我需要的确切结果。我没有在结尾使用
orderby
关键字,我总是这样做,因为应用会明显破坏订单

是否有办法确保查询将按以下顺序返回数据?对我来说,我可以通过
1,2,3
“分区”来修复顺序,而不是将其应用于过高的值,这一点非常重要。我希望你能理解


欢迎提出任何想法。

您应该能够添加一个字段来实现此目的,例如:

1. select something, date_something from my_table
where [conditions]
union
2. select something, date_something from my_table
where [conditions]
union
3. select something, date_something from my_table
where [conditions]

只有使用ORDERBY子句,才能确定行的顺序。
UNION ALL
是否修复了它?
UNION
所做的重复抑制可能会破坏order.OMg,真不敢相信我没有弄明白。谢谢:)
select 1 as Partition, something, date_something 
from my_table 
where [conditions] 
union 
select 2 as Partition, something, date_something 
from my_table 
where [conditions] 
union 
select 3 as Partition, something, date_something 
from my_table 
where [conditions] 
order by Partition