在UNION ALL mysql子句中的行默认顺序?先取出哪一行,我的意思是?

时间:2022-09-05 16:42:17

If I, for example, have a real simple query:

例如,如果我有一个真正简单的查询:

SELECT 1 UNION ALL SELECT 2

SELECT 1 UNION ALL SELECT 2

and then fetch rows via Perl or PHP - would I have "1" as a FIRST row, and "2" as a SECOND? Is this behaviour described anywhere?..

然后通过Perl或PHP获取行 - 我会将“1”作为第一行,将“2”作为第二行吗?这种行为是否在任何地方描述?

Thanx

1 个解决方案

#1


3  

There's no default order, not in tables and not in queries, unless you specify an explicit order with ORDER BY.

除非您使用ORDER BY指定显式订单,否则没有默认订单,不在表中而不在查询中。

You would probably have 1 as first row, and 2 as second, but it's not default behaviour and it's not described anywhere. It's just coincidence!

你可能有1作为第一行,2作为第二行,但它不是默认行为,它没有在任何地方描述。这只是巧合!

#1


3  

There's no default order, not in tables and not in queries, unless you specify an explicit order with ORDER BY.

除非您使用ORDER BY指定显式订单,否则没有默认订单,不在表中而不在查询中。

You would probably have 1 as first row, and 2 as second, but it's not default behaviour and it's not described anywhere. It's just coincidence!

你可能有1作为第一行,2作为第二行,但它不是默认行为,它没有在任何地方描述。这只是巧合!