Hi Chris: I just tried it, but it did not work.
I searched the web and as far as I understand the syntax for LIKE takes this format: string LIKE pattern [ ESCAPE escape-character ] See http://www.redhat.com/docs/manuals/database/RHDB-7.1-Manual/sql/functions-matching.html I think I need "pattern" to have the "% %" in between, but the problem is that Once I put "BadWords" in the quotes "%BadWords%" SQL no longer recognises it as a column in that table. Anyone one have any other suggestions on this !! Louis. "Chris Barnes" <[EMAIL PROTECTED]> wrote: you might find that if you use percent symbols (%) before and after the string in your LIKE statement you will get better results e.g. select BadWords FROM WordsTable WHERE "%this is a test%" LIKE BadWords; i think this tells MySQL to match it anyway it can...all the words or just some..where as with out the % it will try to match the string in the same case (upper or lower) and all the words (i think). I'm not a MySQL guru but i think that will help :) -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Louis Selvon Sent: Tuesday, 13 August 2002 11:47 AM To: [EMAIL PROTECTED] Subject: [SLUG] MYSql and Pattern matching Simple Question Hi: I have read about MYSQL "LIKE", and "REGEXP", but am having problem doing a simple pattern matching. Here is what I want to achieve. I have a string for e.g. called "this is a test" . I would like to search the SQL databases to see if any of the words in that string can be found in the forbidden words sql database. The databases itself just have one column with rows of restricted words. A sample of this DB is shown below ----------- BadWords (Column name) test (row 1) aaa (row 2) bbb (row 3) ----------- I tried the following commands with no success: 1. select BadWords FROM WordsTable WHERE "this is a test" LIKE BadWords; 2. select BadWords FROM WordsTable WHERE "this is a test" LIKE "%BadWords%"; 3. select BadWords FROM WordsTable WHERE BadWords LIKE "this is a test"; But if I change the string to "test" only with the above commands, I get something back (row 1 of table) for commands 1. and 3. above. Any suggestion on how I can get this to work with strings, please let me know. Louis. -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
