请教 order by 后面跟表达式或子查询的困惑
order by 表达式:
请教一:order by 1+1 不等价于 order by 2 的原因?
mysql [email protected]:security> select id from users order by 1+1; +------+ | id | |------| | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | +------+ 8 rows in set Time: 0.003s mysql [email protected]:security> select id from users order by 2; (1054, "Unknown column '2' in 'order clause'")
order by (子查询)
请教二:order by (select 0)不等价于 order by 0 的原因?
mysql [email protected]:security> select * from users order by 0; (1054, "Unknown column '0' in 'order clause'") mysql [email protected]:security> select 0; +-----+ | 0 | |-----| | 0 | +-----+ 1 row in set Time: 0.002s mysql [email protected]:security> select * from users order by (select 0); +------+------------+------------+ | id | username | password | |------+------------+------------| | 1 | Dumb | Dumb | | 2 | Angelina | I-kill-you | | 3 | Dummy | [email protected] | | 4 | secure | crappy | | 5 | stupid | stupidity | | 6 | superman | genious | | 7 | batman | mob!le | | 8 | admin | admin | +------+------------+------------+ 8 rows in set Time: 0.005s
另外,这种问题的解决思路是怎么样呢,只有调试源码这一条困难之路么?