MySQL some columns Distinct
Posted
by
Adam
on Stack Overflow
See other posts from Stack Overflow
or by Adam
Published on 2012-04-07T05:25:20Z
Indexed on
2012/04/07
5:29 UTC
Read the original article
Hit count: 115
mysql
I have the following query that works well.
SELECT DISTINCT city,region1,region2 from static_geo_world where country='AU' AND
(city LIKE '%geel%' OR region1 LIKE '%geel%' OR region2 LIKE '%geel%' OR region3 LIKE '%geel%' OR zip LIKE 'geel%') ORDER BY city;
I need to also extract a column named 'id' but this messes up the DISTINCT as each ID is different.
How can I get the same UNIQUE set of records as above but also get the 'id' for each record? Note: sometimes I can return a few thousand records so a query for each record isn't possible.
Any ideas would be very welcome...
© Stack Overflow or respective owner