本文介绍了使用两列的mysql顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个包含Createdon和Lastmodifiedon字段的表,我必须首先显示基于createdon的新添加的记录,然后显示使用mysql的lastmodifiedon记录.我试图在查询的末尾添加"ORDER BY Createdon,Lastmodifiedon desc";但是仅基于第一列进行排序.任何人都可以帮助解决此问题

I am using a table which has Createdon and Lastmodifiedon fields, I have to display first the newly added record based on createdon and then followed by lastmodifiedon records using mysql. I have tried adding "ORDER BY Createdon,Lastmodifiedon desc" at the end of the query;but sorting based on first column only occurs. Anyone please help in this issue

谢谢.

推荐答案

您正在按升序对Createdon进行排序,因此较新的记录将显示在末尾:

You are sorting Createdon in ascending order, so newer records appear at the end:

ORDER BY Createdon,Lastmodifiedon desc

您需要:

ORDER BY Createdon DESC, Lastmodifiedon DESC

这篇关于使用两列的mysql顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 16:29