When I run my select
SELECT id, MAX(amount) AS value FROM bids
It seems to return the wrong id… it returns the first id value rather then the MAX(amount) selected id.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s expected – you’re using an aggregate function without any ‘group by’ clause. MySQL is being polite and assuming you want a GLOBAL max on the table, whereas you most likely wanted to do this: