I am facing a problem with writing a MySQL query to fetch distinct results. Here is the scenario: I have a table named city as shown below. I have around 131k records now. I have to select the distinct cities. I tried to do substring but I don’t know the length for each. Help in this regard is appreciated.
City
33098 Paderborn
Paderborn
Berlin
02826 Görlitz
10829 Berlin
Görlitz
You have a problem with string formats. If you assume that the numbers are at the beginning or end, you can use something like:
This assumes that the only issue is the sequence of numbers and spaces at the beginning (or end) of the city name.