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
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%\';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.