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,169
  • 9
  • 48
  • 67

4 Answers4

4

Add quotes around your search string.

Scott Saunders
  • 28,922
  • 14
  • 55
  • 63
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
  • 53,986
  • 28
  • 88
  • 159
1

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

SELECT * FROM pages WHERE MATCH (shdescript,ldescript) AGAINST ('romance', 'relationship')
Andy Jones
  • 6,099
  • 4
  • 30
  • 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,508
  • 36
  • 56