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?

0

1 Answer 1

-1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.