frosty frosty - 5 months ago 9
PHP Question

Selecting strings from database that doesn't have questions marks not at the end

I'm trying to select strings from my database which doesn't have question marks that's not at the end. For example:

How? Um?

^---should not be selected, since there is a question mark that's not at the end, in the string.

Here is my query:

SELECT response FROM allData WHERE response NOT REGEXP '[?]\\(?!$\\)'


^---My query doesn't work, and is selecting strings with question marks not at the end.

What am I doing wrong?

Answer

Maybe work for you, try it. :D

SELECT response FROM allData WHERE LOCATE('?', response) = LENGTH(response)