sql的一些知识_order by

注释

 

SELECT name FROM userinfo

#这是注释

/*
这是多行注释
*/

 

 

order by 排序()

SELECT username FROM userinfo ORDER BY userid

 

order by 按多个列排序(weight从小到大,相同的按age从小到大)

SELECT username,weight,age FROM userinfo ORDER BY weight,age
SELECT username,weight,age FROM userinfo ORDER BY 2,3

以上两个语句效果一样

 

order by 降序排序(weight降序,age升序)

SELECT username,weight,age FROM userinfo ORDER BY weight DESC,age;

 

posted @ 2017-11-17 16:42  月河  阅读(189)  评论(0编辑  收藏  举报