johnsmith153 Posted August 24, 2010 Share Posted August 24, 2010 field1 / field2 10 / England 15 / Italy 20 / France 15 / France 30 / USA When searching for France: SELECT DISTINCT field2, field1 FROM $tableName would return a distinct value. I want to ensure it returns the highest value in field1. Something like this: SELECT DISTINCT field2 (but ensure returns highest field 1 value), field1 FROM $tableName Quote Link to comment https://forums.phpfreaks.com/topic/211611-pull-distinct-value-from-database/ Share on other sites More sharing options...
Adam Posted August 24, 2010 Share Posted August 24, 2010 You can use: SELECT DISTINCT MAX(field2), field1 FROM $tableName Quote Link to comment https://forums.phpfreaks.com/topic/211611-pull-distinct-value-from-database/#findComment-1103117 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.