Derek Kalweit <> wrote:
> Hello. I have table1 with thousands of records, with about 8 fields
> of interest. I also have a list(could be in a table) that contains
> bad words. I want a select statement that will allow me to find all
> the table1 records that have a 'bad word' in any of the 8 fields.  
> 
> This is easy to brute force with a single bad word-- just do this:
> 
> select * from table1 where field1 like '%bad1%' or field2 like
> '%bad2%' 
> 
> etc.
> 
> I'm hoping for something like this, but I don't believe it exists:
> 
> select * from table1 where field1 like (select cword from badwords) or
> field2 like (select cword from badword)
> 
> 
> Any advice on how to do this with some clever MySQL-compatible SQL,
> or will I be forced to do this client-side? 
> 
> Any ideas appreciated. Thanks.

Select * from Table1
Where field1 in (select bad words from table2)
Union
Select * from Table1
Where field2 in (select bad words from table2)

Continue till all columns are processed.

HTH


Stephen Russell
DBA / .Net Developer

Memphis TN 38115
901.246-0159

"A good way to judge people is by observing how they treat those who
    can do them absolutely no good." ---Unknown

http://spaces.msn.com/members/srussell/

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.467 / Virus Database: 269.6.1/778 - Release Date: 4/27/2007
1:39 PM
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to