rstewar Posted February 4, 2010 Share Posted February 4, 2010 Is there a way to select only unique records from a database, where only one value is unique? I want to be able to select unique values for 'university_1', but 'latitude' and 'longitude' do not have to be unique. $sql = "SELECT university_1, latitude, longitude FROM stores "; $sql .= "WHERE state='$state' AND "; $sql .= "latitude BETWEEN '$min_lat' AND '$max_lat' AND longitude BETWEEN '$min_lon' AND '$max_lon' AND approved=1 AND status=1"; Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/190936-selecting-unique-value-for-mysql-database/ Share on other sites More sharing options...
Hybride Posted February 4, 2010 Share Posted February 4, 2010 Try: $sql = "SELECT DISTINCT(university_1), latitude, longitude FROM stores "; Link to comment https://forums.phpfreaks.com/topic/190936-selecting-unique-value-for-mysql-database/#findComment-1006902 Share on other sites More sharing options...
rstewar Posted February 4, 2010 Author Share Posted February 4, 2010 Works great. Can't believe I didn't think of that. Thanks Link to comment https://forums.phpfreaks.com/topic/190936-selecting-unique-value-for-mysql-database/#findComment-1006912 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.