1

Possible Duplicate:
Order of LIKE clause in query when wanting to use multiple terms

I am attempting to make a search function on my website. I want to search more than one field.

for example:

$sql=mysql_query("select * from inventory WHERE MATCH (pn, description, location, notes) AGAINST ('{$q}')  ORDER BY {$sort} {$direction}") or die(mysql_error());

The above searches pn, description, location, and notes. But it only searches for exact matches. So I'm wanting to use:

$sql=mysql_query("select * from inventory where pn like '%{$q}%'") or die(mysql_error());

But search more than one field like the above. How can I go about doing this?

Aldwoni
  • 1,168
  • 10
  • 24
alexander7567
  • 665
  • 13
  • 35
  • All you needed was `IN BOOLEAN MODE` in your fulltext style query. Example `... SELECT * FROM inventory WHERE MATCH (pn, description, location, notes) AGAINST ('{$q}' IN BOOLEAN MODE) ORDER BY ...` – Anthony Hatzopoulos Dec 11 '12 at 16:37

0 Answers0