JonnoTheDev Posted September 16, 2009 Share Posted September 16, 2009 I need a quick solution to extract duplicates into a temporary table for review. The duplicates are to be found where the longitude and latitude values are identical (not just one column). The placenames that differ but have the same long & lat will need their geo data checked so I do not want to delete just yet. Structure: cities ====== cityId regionId title longitude latitude i.e. 1, 1, citya, 10.1, 45.2 2, 4, cityb, 10.1, 45.2 Quote Link to comment https://forums.phpfreaks.com/topic/174478-solved-finding-duplicates-from-2-columns/ Share on other sites More sharing options...
kickstart Posted September 16, 2009 Share Posted September 16, 2009 Hi Quick attempt. Something like this should do it:- SELECT * FROM cities a INNER JOIN (SELECT longitude, latitude, COUNT(title) AS citycount FROM cities GROUP BY longitude, latitude) b ON a.longitude = b.longitude AND a.latitude = b.latitude WHERE citycount > 1 All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/174478-solved-finding-duplicates-from-2-columns/#findComment-919616 Share on other sites More sharing options...
JonnoTheDev Posted September 17, 2009 Author Share Posted September 17, 2009 Thanks, I can work with that result set Quote Link to comment https://forums.phpfreaks.com/topic/174478-solved-finding-duplicates-from-2-columns/#findComment-919992 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.