Consider the following messages:
id message
------------------------------------------------------------
1 $AA is the only way to go!
2 This is my $AA. There are many like it.
3 But this is my $AA.
4 My$AA is my swag.
5 For lack of imagination a message with $AA in the middle.
6 Another message with at the end: $AA
I want to filter all messages with $AA:
- $AA could be at the beginning of the message (so: only a space after it)
- $AA could be at the end of a message (so: only a space before it)
- $AA could be anywhere else in the message (surrounded by spaces)
- $AA could have punctuation before and/or after it: $AA. $AA, or ($AA)
- But not any other charachters (letters and numbers)
I would normally use a query such as
SELECT * FROM messages WHERE message LIKE '%$AA%'
But then message 4 is also returned. How can I made the query not return message 4?
It’s too easy just add a space in your query like this-
This will not cover first row for that
use this: