PeterErhard
asked on
mysql query
I have a whole heap of spam in a table that I'm trying to get rid of.
What makes the posts the same is the following text:
However when I search for it with the below query I get 0 results back which I assume is because of those % wildcard characters. How can I get around this to show all comments with the above text within them? Please ignore the /url tag because EE is asking me to put that in.
SELECT *
FROM FeaturesComments
WHERE COMMENT LIKE ''
and ApprovalStatus = 0
What makes the posts the same is the following text:
[url=%url%][/url]
However when I search for it with the below query I get 0 results back which I assume is because of those % wildcard characters. How can I get around this to show all comments with the above text within them? Please ignore the /url tag because EE is asking me to put that in.
SELECT *
FROM FeaturesComments
WHERE COMMENT LIKE ''
and ApprovalStatus = 0
I'm confused. Why don't you show us an actual entry? Put it in the code section.
To escape the % sign we need \%. In addition, we need a wild card % to use the like statement.
For example, in your search string, we need to escape the embedded % sign and then use actual % for wildcard, please try this
For example, in your search string, we need to escape the embedded % sign and then use actual % for wildcard, please try this
SELECT *
FROM FeaturesComments
WHERE COMMENT LIKE '%[url=\%url\%][ /url]%'
and ApprovalStatus = 0
Please show us the actual data. You can find this with phpMyAdmin. You can copy it and paste it into the code snippet here at EE. This will help us get you a better answer.
ASKER
Apologies for the late response.
An attached sample comment is attached.
The below query doesn't find it:
An attached sample comment is attached.
The below query doesn't find it:
SELECT *
FROM FeaturesComments
WHERE COMMENT LIKE '%[url=\%url\%][ /url]%'
and ApprovalStatus = 0
ASKER
Forgot to attach.
spam.txt
spam.txt
Try
like '[url=\%url\%]%[/url]'
ASKER
Thanks clockwatcher, but your query doesn't find it.
Duh... sorry... forgot it had stuff before it... too early in the morning.]
like '%[url=\%url\%]%[/url]'
ASKER
That did the trick, thank you very much :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Apologies for the late accept.
SELECT *
FROM FeaturesComments
WHERE COMMENT LIKE '[ url=\%url\% ][ /url]'
and ApprovalStatus = 0
But really think there is probably something else going on.