[thelist] mysql query - replacing characters

Jeremy Weiss eccentric.one at gmail.com
Tue Aug 4 03:09:48 CDT 2009


I'm trying to write a query that will combine two fields and then remove all
non-letter and non-number characters. 

SELECT unique_id,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(CONCAT(street_num,' ',
street_name),' ',''),'-',''),'/',''),'#',''),'.','') AS address FROM
listings HAVING address LIKE '%123EasySt%'

Now, this works up to what I have there. But, if I try to add an additional
REPLACE to it, it kicks up an error saying something's wrong with my syntax.

I guess my first question is, is there a better way to write this query? And
if not, why won't it accept more nested replace statements?

Thanks.

-jeremy






More information about the thelist mailing list