lisovaccaro
lisovaccaro

Reputation: 33956

MySQL query to search for MATCH in 3 columns?

I created a FULLTEXT Index for columns: City, Group and Text called city_group_text_comparator

How do I do a simple query to look up a string on all 3?

I tried this:

$result = mysql_query("SELECT * FROM Posts WHERE MATCH (City, `Group`, Text) AGAINST ('$search') LIMIT $limit_posts OFFSET $first_post");

How does it order the results?

Thanks

Upvotes: 0

Views: 447

Answers (1)

lisovaccaro
lisovaccaro

Reputation: 33956

My example was actually right:

Adding inverted quotes around Group did the trick:

$result = mysql_query("SELECT * FROM Posts WHERE MATCH (City, `Group`, Text) AGAINST ('$search') LIMIT $limit_posts OFFSET $first_post");

Probably it's a reserved value for MySQL, honestly don't know why, but nevertheless it works this way.

Upvotes: 2

Related Questions