With the following query
SELECT * FROM words WHERE word REGEXP '(ord)'
- This will return words like
ford
,lord
,word
How can I include words where these letters appear but not in the same order?
- For example
adore
,door
,random
Edit:
Got this working.
SELECT word, (
IF(LOCATE('o', word) > 0, 1, 0) +
IF(LOCATE('r', word) > 0, 1, 0) +
IF(LOCATE('z', word) > 0, 1, 0) +
IF(LOCATE('a', word) > 0, 1, 0) +
IF(LOCATE('d', word) > 0, 1, 0)) AS chars_present
from words
HAVING chars_present = 5
Now how would I query for words containing the letter r
twice?