标签:默认 淘宝 log 语句 website https span code googl
ORDER BY 关键字用于对结果集进行排序。
下面是选自 "Websites" 表的数据:
+----+--------------+---------------------------+-------+---------+
| id | name | url | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1 | Google | https://www.google.cm/ | 1 | USA |
| 2 | 淘宝 | https://www.taobao.com/ | 13 | CN |
| 3 | 菜鸟教程 | http://www.runoob.com/ | 4689 | CN |
| 4 | 微博 | http://weibo.com/ | 20 | CN |
| 5 | Facebook | https://www.facebook.com/ | 3 | USA |
+----+--------------+---------------------------+-------+---------+
SELECT * FROM Websites ORDER BY alexa;
输出
下面的 SQL 语句从 "Websites" 表中选取所有网站,并按照 "alexa" 列降序排序:
SELECT * FROM Websites ORDER BY alexa DESC;
执行输出结果:
下面的 SQL 语句从 "Websites" 表中选取所有网站,并按照 "country" 和 "alexa" 列排序:
SELECT * FROM Websites ORDER BY country,alexa;
ORDER BY 多列的时候,先按照第一个column name排序,在按照第二个column name排序;如上述教程最后一个例子:
标签:默认 淘宝 log 语句 website https span code googl
原文地址:http://www.cnblogs.com/yinghuali/p/7783338.html