Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Confusion about MAX in query
11-03-2013, 03:16 PM #1
- Join Date
- Aug 2012
- Thanked 3 Times in 3 Posts
Confusion about MAX in query
I have set up the following query.
SELECT MAX(businessInfo.id) AS refID, businessInfo.id AS checkID,
FROM businessInfo, members
WHERE businessInfo.memberID = members.id
AND members.membershipType = 'CORP'
GROUP BY members.business
ORDER BY members.business ASC
What am I missing?
By way of explanation of the need, we need to keep a record of all the changes in business info on the database so each time a change is made a new entry is made.
Last edited by rgEffects; 11-03-2013 at 03:19 PM.
11-03-2013, 03:20 PM #2
- Join Date
- Oct 2006
- Denver, Colorado USA
- Thanked 304 Times in 296 Posts
If you want the actual row holding a specific value within the group, see this - http://dev.mysql.com/doc/refman/5.0/...group-row.html
Just using MAX() gives you the maximum value for that column within the group, not the row it is in.
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.