MySQL按2列排序 [英] MySQL Sort By 2 Columns

查看:78
本文介绍了MySQL按2列排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子,上面放着电视节目的信息,我想按季节,然后按情节排序.这是我所拥有的基本观点:

I have a table which holds information on television programs and I want to order it by Seasons and then by episodes. Here's a basic view of what I have:

+---+--------+---------+
|id | Season | Episode |
+---+--------+---------+
| 1 |    1   |    1    |
+---+--------+---------+
| 1 |    1   |    2    |
+---+--------+---------+
| 1 |    2   |    1    |
+---+--------+---------+
| 1 |    2   |    3    |
+---+--------+---------+

所以我按季节选择我需要的东西和订单.但是每个季节之间会有很多事情,所以我也需要对情节进行排序,但又不影响季节.

So I select what I need and order by Season. But there's going to be a lot between seasons so I need to sort episodes too, but without it affecting seasons.

推荐答案

您的意思是:

SELECT id, Season, Episode 
FROM table 
ORDER BY Season ASC, Epsisode ASC

按多列排序很简单.

这篇关于MySQL按2列排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆