i want to select the data in a table such that it should group it by userid except one value in that column and order by date time and desc. The problem i am getting is the grouped items are not ordering by date and time and in desc manner. I mean the grouped item is showing earlier row. How can i do that. This is what i have done.
SELECT * FROM `tbljobs`
GROUP BY user_id
UNION ALL
SELECT * FROM tbljobs
WHERE user_id = '1'
ORDER BY date_time DESC
LIMIT 20"
where '1' is should not be grouped.