Reputation: 3410
I'm trying to SELECT all rows that have an hyphenated word in a certain column. This is what I have so far:
SELECT * FROM MyTable WHERE list RLIKE '\w-\w'
But it's only returning 1 row, when I know there are a lot more. Any ideas why?
Thank you
| List |
built-in
self-discipline
hang-up
....
EDIT: Not sure if it matters, but list is utf8_unicode_ci
Upvotes: 0
Views: 47
Reputation: 25842
if you want to try and use it without regex then try the wildcard.. not sure if you are not able to use that or not, but that should work too
SELECT * FROM MyTable WHERE list LIKE '%-%'
Upvotes: 0
Reputation: 780871
MySQL regular expressions don't support \w
(or any other escape sequences for character classes). You must write:
SELECT * FROM MyTable WHERE list RLIKE '[[:alnum:]_]-[[:alnum:]_]'
See the Documentation for details of MySQL regular expressions.
Upvotes: 2