我有这个问题:
SELECT * FROM project as p inner join users as u on p.user_id = u.user_id
ORDER BY p.projectname, u.date_joined
现在我想要ORDER by projectname ASC
和u.date_joined DESC
。
我怎么能这样做?我在这里尝试了这段代码,但不起作用:
SELECT * FROM project as p inner join users as u on p.user_id = u.user_id
ORDER BY p.projectname ASC, u.date_joined DESC
订购项目名称升序,但降序不起作用。
答案 0 :(得分:1)
要订购项目名称降序,请执行以下操作:
SELECT *
FROM project p
INNER JOIN users u ON p.user_id = u.user_id
ORDER BY p.projectname DESC, u.date_joined DESC
这将首先按项目名称desc(Z到A)排序结果。对于相同的projectname记录,date_joined将用于进一步排序(最新日期优先)。