php - In mysql, how can I select the numeric portion of a field? -
i have table containing free-form phone numbers (e.g. '123-456-7890', '(987) 654-3210', or '123.456.7890') , i'm searching them numeric string- e.g., '123456'.
right now, i'm having bunch of replace(replace(replace(.. advertisement nauseum functions strip out errant non-numeric characters utilize 'like' search value search.
anyone know of simpler way select characters field based on type, not position?
you can utilize regex in mysql -
select * `table` `phone` regexp '^[12345]'
here working example.
php mysql
No comments:
Post a Comment