如何按日期对下面的查询进行排序? [英] How to sort the query below by date?
问题描述
嗨php专家,
想问下面的查询是否正确返回按日期排序的结果?非常感谢。
$ date_query =从时间表中选择日期ID =(从时间表中选择最大值(ID),其中status = 1,userID ='。$ row ['ID']。')按日期排序desc;
我尝试了什么:
以下代码有效,但日期未排序。谢谢。
$ date_query =从时间表中选择日期ID =(从时间表中选择最大值(ID),其中status = 1,userID ='。$ row ['ID ']。');
Hi php experts,
Would like to ask if the query below is correct to return results sort by date? Thanks a lot.
$date_query = "select date from timesheet where ID = (select max(ID) from timesheet where status=1 and userID='".$row['ID']."') order by date desc";
What I have tried:
The code below is working but the dates are not sorted. Thanks.
$date_query = "select date from timesheet where ID = (select max(ID) from timesheet where status=1 and userID='".$row['ID']."');
推荐答案
date_query =从时间表中选择日期ID =(从时间表中选择最大值(ID),其中status = 1,userID =' 。
date_query = "select date from timesheet where ID = (select max(ID) from timesheet where status=1 and userID='".
row ['ID']。')按日期排序desc;
我是什么尝试过:
以下代码有效,但日期没有排序。谢谢。
row['ID']."') order by date desc";
What I have tried:
The code below is working but the dates are not sorted. Thanks.
date_query =从ID =的时间表中选择日期(从时间表中选择最大值(ID),其中status = 1,userID ='。
date_query = "select date from timesheet where ID = (select max(ID) from timesheet where status=1 and userID='".
这篇关于如何按日期对下面的查询进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!