Subquery Like and Wildcards

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Is a query like this possible?  I'm trying to filter out for words
that exist in a filter table.  I'd like to filter for foul language,
but for example:

"Cat" is in the filter table.
It should also filter:


FROM tresponsecomments
WHERE comment NOT LIKE '%(Select filtered from tfilteredWords)%'
LIMIT 0 , 30


Re: Subquery Like and Wildcards

Quoted text here. Click to load it

a) To answer you question, have you tried it?
b) This is not a SQL forum
c) Wouldn't it make more sense to filter out profane comments *before*
inserting them into the database?

Re: Subquery Like and Wildcards

Good point, I was developing in PHP and instinctively came to this
Quoted text here. Click to load it

Re: Subquery Like and Wildcards

Quoted text here. Click to load it

It might work better if you put "%cat%" in the table.  Another possibility
is to concatenate the %'s in the subquery, such as:
    SELECT CONCAT('%', badword, '%') FROM ...

You really ought to consider whether this is a good idea, especially
without an exception table.  For example, filtering "ass" gets 1381
other words in the dictionary file on my computer, including words
such as "grass", "glass", and "assemble".

You also get non-dictionary words such as "Massachusetts", "Mass.",
"Douglass", and "Kass", which don't appear as a dictionary word but
some of them might appear in customer names or addresses.

Site Timeline