SQL基础【七、Order by】

2022-11-28 17:13:03 浏览数 (1)

1:对指定列进行升序排列

Select * from user order by user_name

2:按照user_id逆序排列

Select * from user order by user_id DESC

2:按照升序排列user_id逆序排列user_age

SELECT * FROM user order by user_id ASC,user_age DESC

3:按照升序排列user_id逆序排列user_age

SELECT * FROM user order by user_age DESC,user_id ASC

注意:前面的条件优先级更高!!

希望能对大家有所帮助。

0 人点赞