frosty frosty - 1 year ago 67
SQL Question

Selecting a sentence in mysql starting with a word, and NOT followed by another word

I'm trying to select a sentence in mysql starting with the word 'by' and NOT followed by the word 'the', but it's not working somehow. What am I doing wrong?

FROM `allData`
WHERE response REGEXP '^by ?!the'

Answer Source

mysql regex doesn't support positive or negative lookeaheads. alternatively you could do something like

response REGEXP  '^by ' and response not like 'by the%'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download