SELECT语句中表达式的执行顺序 [英] Execution order of expressions in SELECT statement
本文介绍了SELECT语句中表达式的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道SELECT
语句中表达式的执行顺序是否总是从从左到右.
I want to know if the execution order of expressions in SELECT
statement always takes place from left to right.
SET @a := 0;
SELECT
@a AS first,
@a := @a + 1 AS second,
@a := @a + 1 AS third,
@a := @a + 1 AS fourth,
@a := @a + 1 AS fifth,
@a := @a + 1 AS sixth;
是否保证上述查询将始终生成以下输出?
Is it guaranteed that the above query will always generate the following output?
first second third fourth fifth sixth
0 1 2 3 4 5
推荐答案
根据 MySQL manual
:
但是,涉及用户的表达式的求值顺序 变量未定义
However, the order of evaluation for expressions involving user variables is undefined
所以您的问题的答案是否",不能保证执行顺序.
So the answer to your question, is no, the execution order is not guaranteed.
这篇关于SELECT语句中表达式的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文