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 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 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
Archived
This topic is now archived and is closed to further replies.