时间:2022-12-06 01:18
1.首先,在命令行中启动MySQL服务;
service mysql start
2.MySQL服务启动后,在命令行中输入mysql的用户名和密码登录到MySQL;
mysql -u root -p
3.登录到MySQL后,选择使用一个数据库;
use mysql;
4.最后,进入到数据库后,在数据库中执行以下命令即可对排序号进行输出;
SELECT a.*,@rank:=@rank + 1 AS rank_no
FROM (
SELECT *
FROM `logs`
WHERE log_created> "2017-09-01"
ORDER BY count DESC
) a, (SELECT @rank:= 0) b