I have a table called items. IN this table there are many columns. One of the columns is called ‘source’. What I would like to do is select records from the table. I would like to select the latest 5 records with the condition that the ‘source’ columns are all distinct.
I tried the following:
SELECT DISTINCT SOURCE from items order by time DESC LIMIT 5
but I need the whole record not just the source, when I try to include more columns it doesn’t work .
I tried this:
SELECT * FROM items WHERE item_section='sp_500' GROUP BY source ORDER BY time DESC LIMIT 3
but it doesn’t give me the LATEST records
Tricky.
Try this.