ChrisM ChrisM - 1 month ago 6
MySQL Question

SQL- Dashes causing duplication

I have a query which returns over 150k rows.

Of these 150k there are a handful of problematic rows which are duplicated due to the "License Number" field having results with/without dashes

License Number
LA-637784
LA637784
LA-971867
LA971867
LA1177043
LA-1177043
LA808748
LA-808748


Is there any small function that would filter out the value with/without the dash?

There are lots of other valid results with dashes so i can't just filter out all dashes.

Thanks

Answer

Use Replace() and then a distinct

select distinct replace(LicenseNumber, '-', '') as LicenseNumber
from MyTable
Comments