Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mySQL - weird results 1

Status
Not open for further replies.

soundmind

Technical User
Jun 30, 2003
16
US
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!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top