Here's a sample table:
Columns:
table_id(primary, auto_increment), item_number, user_name, entry_date
Each time a user logs in, they record an item, their user_name and an entry_date.
Sometimes there will be duplicates of item_id, but only one entry per user.
I tried to get the latest entry for a user and did:
SELECT MAX(entry_date) entry_date, item_number
FROM table
WHERE user_id=3
GROUP BY site_id
It gives me the correct MAX(entry_date) but not the corresponding item_number. I tried HAVING, GROUP BY, ORDER BY... anything I can find. But will not work. Can you help me?
Thanks!
Columns:
table_id(primary, auto_increment), item_number, user_name, entry_date
Each time a user logs in, they record an item, their user_name and an entry_date.
Sometimes there will be duplicates of item_id, but only one entry per user.
I tried to get the latest entry for a user and did:
SELECT MAX(entry_date) entry_date, item_number
FROM table
WHERE user_id=3
GROUP BY site_id
It gives me the correct MAX(entry_date) but not the corresponding item_number. I tried HAVING, GROUP BY, ORDER BY... anything I can find. But will not work. Can you help me?
Thanks!