Forum Moderators: open

Message Too Old, No Replies

MySQL: select multiple keywords from multiple tables.

         

jsprague

6:44 am on Dec 16, 2008 (gmt 0)

10+ Year Member



Hello,

I am not very good with mysql and I am having problems writing a particular select statement. Here is what I am trying to do. I have a database called "members" that contains a table called "Reviews". This table has fields S1, S2, S3, S4, etc. that I want to search for the words ad, advertisement, and promotion. Here is the syntax I came up with that doesn't work:

SELECT * FROM `REVIEWS` WHERE S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, XTRA='ad, advertisement, promotion'

It would be perfectly fine, if easier, to search all fields in the table.

Any help would be very much appreciated!
Thanks,
Jason

phranque

9:06 am on Dec 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



this might work:

SELECT * FROM `REVIEWS` WHERE S1 REGEXP "ad¦advertisement¦promotion" OR S2 REGEXP "ad¦advertisement¦promotion" OR S3 REGEXP "ad¦advertisement¦promotion" OR ...

jsprague

9:30 am on Dec 16, 2008 (gmt 0)

10+ Year Member



Thanks for the help..

That is close, however, it doesn't seem to like keyword¦keyword. It always returns an empty search result. I tried commas instead of ¦ and that didn't work either. It works fine if I only enter 1 keyword within the quotes.

Thanks again!

topr8

12:07 am on Dec 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the ¦ sign should be a solid line, but WebmasterWorld replaces it with a broken line!

phranque

1:21 am on Dec 17, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



sorry - i forgot to remind you about replacing that broken pipe symbol...

jsprague

2:12 am on Dec 17, 2008 (gmt 0)

10+ Year Member



Thanks very much to you both.. That worked perfectly!

Happy holidays!