Reputation: 3
In my MySQL i want to look for characters in a specific ORDER...
the following code doesn't care how 'o' 'l' 'd' appear... so words containing those characters would be matched...
I'm only interested in doing the match if 'o' appears first, 'l' second and 'd' third.
Alternatives to REGEXP are also welcome!
SELECT DISTINCT(col)
FROM tab
WHERE col REGEXP 'o'
AND col REGEXP 'l'
AND col REGEXP 'd'
GROUP BY col
ORDER BY col DESC
Upvotes: 0
Views: 53
Reputation: 146
You should try the following
SELECT col
FROM tab
WHERE col like "%o%l%d%"
ORDER BY col DESC
Upvotes: 1