我有这样一个问题:
SELECT A.*,
B.surname,
B.name,
C.url_address,
(SELECT Concat(file_path, '/', file_name) AS image
FROM psuploadedfiles B
WHERE enum = 3
AND category = A.id_user
ORDER BY number ASC
LIMIT 1) AS image2,
(SELECT Concat(file_path, '/', file_name) AS image
FROM psuploadedfiles B
WHERE enum = 3
AND category = A.post_id
ORDER BY number ASC
LIMIT 1) AS image
FROM psposts A
LEFT JOIN psuserdetails B
ON B.id_user = A.id_user
LEFT JOIN psuser C
ON C.id_user = A.id_user
WHERE A.enable = '1'
AND ( A.id_user = 21
OR ( A.id_user = '7'
OR A.id_user = '1'
OR A.id_user = '5' ) )
ORDER BY date DESC
LIMIT 0, 25;
在psposts表中,我有一个subscriptions\u date列(包含yyyy-mm-dd格式的日期),其中subscriptions\u date是文章升级之前的日期。
如何对结果进行排序,使顶部的帖子包含订阅日期、当前日期或未来日期(即升职日期),而其他帖子则位于下方?
1条答案
按热度按时间m1m5dgzv1#
有点像。。。
第一个排序条件将数据分成两组,当前或将来的订阅放在第一位。在每个组中,数据按
date
.