Jump to content

SQL searching an entire DB for a keyword


rhysmeister

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?

Link to comment
https://forums.phpfreaks.com/topic/528-sql-searching-an-entire-db-for-a-keyword/
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%\';

Archived

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

×
×
  • Create New...

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.