0

I have a table which needs stores some name and i need to replace a few characters before comparing them with another string

For instance, My table data is


abc
ghi:dki
ioe  dsa

i read a string from user, which is of the form abc, ghi-dki, ioe-dsa. ie, all blankspaces, multiples spaces and symbols are converted to a hyphon(-). Now i need to compare. something like

SELECT MYCOLUMN FROM MYTABLE WHERE {Converted MYCOLUMN} = 'ghi-dki'

Can someone help me for figuring out which MySQL function can do it?

Jasir
  • 677
  • 1
  • 8
  • 26

1 Answers1

0

You can't do a regex replace in MySQL, but you can do a match.

SELECT mycolumn FROM tablename WHERE mycolumn REGEXP Replace('ghi-dki', '-', '^[\s:_-]*$');

Note: I didn't completely fill out the symbols character set, you'll have to add whatever you're using.

arychj
  • 711
  • 3
  • 21