Jump to content


Photo

SQL searching an entire DB for a keyword


  • Please log in to reply
2 replies to this topic

#1 rhysmeister

rhysmeister
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts
  • LocationEngland

Posted 30 May 2003 - 10:03 AM

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?

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 30 May 2003 - 10:57 AM

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

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 rhysmeister

rhysmeister
  • Members
  • PipPipPip
  • Advanced Member
  • 51 posts
  • LocationEngland

Posted 30 May 2003 - 11:41 AM

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users