2

I need remove dots and hyphens on a string on compare in Where clause.

This is my query now:

Select * from tbl_sometable where some_column in ('10000000000', '1999999999')

But, the some_column have values like this: '129.012.120-01' and I need filter the values too, like the values in a clause "in".

How I can do this? I using MySQL, I see an example using Translate, but not work in MySQL.

Thanks and best Regards.

Marcos Bergamo
  • 1,073
  • 2
  • 11
  • 19
  • There is a post here that looks like it would solve your problem: http://stackoverflow.com/questions/287105/mysql-strip-non-numeric-characters-to-compare – dub stylee Apr 07 '14 at 17:41

2 Answers2

3
WHERE
  REPLACE
    (
      REPLACE
       (
         some_column, "-", ""
       ), ".", ""
    ) in ('10000000000', '1999999999')
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
2
WHERE REPLACE(REPLACE(some_column, '.', ''), '-', '') in ('10000000000', '1999999999')
Linger
  • 14,942
  • 23
  • 52
  • 79