Here is my query, which tries to put a full stop at the end of every sentence that doesn’t end in proper punctuation
UPDATE SentenceTable SET sentence=concat(sentence, '.') WHERE sentence NOT LIKE '%.' OR sentence NOT LIKE '%?' OR sentence NOT LIKE '%!';
However, this ends up putting a full stop at the end of every single sentence. I’m afraid I have a problem with the regular expressions from above, maybe I am not escaping some special characters correctly? What am I doing wrong? How should this query read?
Thanks!
You’re using
ORbetween each of yoursentence NOT LIKE ..clauses; usingANDshould fix this:The reasoning for this is because, assume the
sentenceends with!, such as “This is a sentence!”. Your very first clause issentence NOT LIKE '%.'. Well, this sentence doesn’t end with a., and because you’re only usingORtheWHERE-clause stops parsing the rest of the clauses. When you switch toAND, it evaluates all of the conditions and since the last one fails, the sentence won’t get updated!