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

Reply via email to