1

I am trying to run a match against query and it is not working. I created a full text index on the two fields. But am getting sql error right before word 'relationship". Here is sql:

"SELECT * FROM pages WHERE MATCH (shdescript,ldescript) AGAINST (romance, relationship)";

I have also tried just searching against shdescript and just searching against ldescript but get same error. Also I've tried searchstring without spaces. As far as I know, you are supposed to have the words of the searchstring separated by commas in parentheses. What am I doing wrong? Thanks.

user1260310
  • 2,229
  • 9
  • 49
  • 67

4 Answers4

4

Add quotes around your search string.

Scott Saunders
  • 29,840
  • 14
  • 57
  • 64
1
"SELECT * FROM pages WHERE MATCH (shdescript,ldescript) AGAINST ('romance', 'relationship')";

Also make sure you protect yourself against the nasty SQL injection threat, read more here.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
1

Try quoting your string (i.e 'romance' and 'relationship')

SELECT * FROM pages WHERE MATCH (shdescript,ldescript) AGAINST ('romance', 'relationship')
Andy Jones
  • 6,205
  • 4
  • 31
  • 47
0

I believe your AGAINST must be in quotes. From:

http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html#function_match

AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a literal string, not a variable or a column name.

Nick
  • 4,901
  • 40
  • 61