Forum Moderators: coopster

Message Too Old, No Replies

SQL regex for matching exact words

         

optik

2:29 pm on Oct 5, 2009 (gmt 0)

10+ Year Member



I'm trying to use this statement with no luck, any ideas?

SELECT name FROM employees WHERE skill_sets REGEXP '[[:<:]]php[[:>:]]'

jd01

4:58 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What are you trying to match?

rocknbil

5:17 pm on Oct 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your title says exact words, is that what you really want? You don't need regexps for exact words,

SELECT name FROM employees WHERE skill_sets = 'php'

or if it's in a list, you can use like,

SELECT name FROM employees WHERE skill_sets like '%php%'

Otherwise, as questioned, the environment and example is going to help answer.

optik

5:42 pm on Oct 5, 2009 (gmt 0)

10+ Year Member



the problem is like '%php%' returns results for things like phpSoap as it searches for strings within words, I need exact word matches only and that are from text/phrases so a simple = is no good

I found the above code online and there is plenty of mention of regexs for sql but it just doesn't seem to work.

optik

6:49 pm on Oct 5, 2009 (gmt 0)

10+ Year Member



I found this which worked...

RLIKE '[[:<:]]php[[:>:]]'