Created
July 28, 2017 10:15
-
-
Save onlinelei/7f07d93c18656797f8b9f3c92d37f9b5 to your computer and use it in GitHub Desktop.
mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- mysql单条SQL查询出分页和总数 | |
SELECT SQL_CALC_FOUND_ROWS t.* FROM ( SELECT 1 AS allCount, | |
dr.id AS reportId | |
FROM dr_daily dr | |
WHERE 1=1 | |
GROUP BY dr.id | |
ORDER BY dr.create_time DESC | |
)t | |
LIMIT 1,2 | |
UNION ALL SELECT FOUND_ROWS() AS allCount, NULL | |
-- 假设要按照用户表 user 用户名 Username 的拼音排序 | |
SELECT * FROM user ORDER BY CONVERT(Username USING gbk) COLLATE gbk_chinese_ci DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment