Jump to content

Archived

This topic is now archived and is closed to further replies.

rhysmeister

SQL searching an entire DB for a keyword

Recommended Posts

This is the SQL statement I am using to search an entire DB table for a keyword

 

SELECT * FROM faults WHERE company OR date OR user

OR product OR version OR issue OR resolution

OR comment OR resolved_by LIKE \'%$keyword%\';

 

The problem is that is pulls out all entries whatever is input. I have echoed $keyword on to the web page and all seems OK there. I also entered the statement into the mysql console and the same result occured, so I guess there\'s something wrong with the statement. Any ideas?

Share this post


Link to post
Share on other sites

Try this :roll:

 

SELECT * FROM faults WHERE company LIKE \'%$keyword%\'OR date LIKE \'%$keyword%\' OR user LIKE \'%$keyword%\'

OR product LIKE \'%$keyword%\'OR version LIKE \'%$keyword%\'OR issue LIKE \'%$keyword%\' OR resolution LIKE \'%$keyword%\'

OR comment LIKE \'%$keyword%\' OR resolved_by LIKE \'%$keyword%\';

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.