Paul
Paul

Reputation: 11746

MySQL Match issue

Referring to my earlier stackoverflow post I'm trying to look for similarities in messages sent via the following:

SELECT id, MATCH (content) AGAINST (content) AS score FROM pms_messages WHERE sender_id = '.$sender_id.' AND MATCH (content) AGAINST (content) AND score > 1;

I see the error: #1210 - Incorrect arguments to AGAINST

I've set a FULLTEXT index on my content field. From phpmyadmin:

 Edit    Drop   fulltext_index  FULLTEXT    No  No  content 1

What am I missing?

Upvotes: 0

Views: 177

Answers (1)

hakre
hakre

Reputation: 197624

Always read the manual when you get an error message, it's helpful most quickly:

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.

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

So what you try to achieve is done wrong. Use a literal string instead of a column name.

See also 11.9.5. Full-Text RestrictionsDocs, specifically:

  • The argument to AGAINST() must be a constant string.

Upvotes: 2

Related Questions