order by 表达式:
请教一:order by 1+1 不等价于 order by 2 的原因?
mysql root@localhost: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 root@localhost: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 root@localhost:security> select * from users order by 0;
(1054, "Unknown column '0' in 'order clause'")
mysql root@localhost:security> select 0;
+-----+
| 0 |
|-----|
| 0 |
+-----+
1 row in set
Time: 0.002s
mysql root@localhost:security> select * from users order by (select 0);
+------+------------+------------+
| id | username | password |
|------+------------+------------|
| 1 | Dumb | Dumb |
| 2 | Angelina | I-kill-you |
| 3 | Dummy | p@ssword |
| 4 | secure | crappy |
| 5 | stupid | stupidity |
| 6 | superman | genious |
| 7 | batman | mob!le |
| 8 | admin | admin |
+------+------------+------------+
8 rows in set
Time: 0.005s
另外,这种问题的解决思路是怎么样呢,只有调试源码这一条困难之路么?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.