Here is a sample data set.
id list_id user_id times
2 1 8 2017-05-25 10:27:18
4 2 8 2017-05-26 12:58:58
6 1 8 2017-06-09 17:28:00
7 2 8 2917-06-09 19:27:36
I have multiple list_id in table. i want to fetch only a single list_id on the basis of latest date. Please help me guys. I am using this query but i am not succeed.
select *
from class_history
where user_id=8
GROUP
BY list_id
ORDER by id DESC
or
select *
from class_history
where user_id=8
GROUP
BY list_id
ORDER by time DESC
Thanks for your support.