PDA

View Full Version : Trying to SELECT *, MATCH() with two columns



NevadaSam
05-24-2007, 12:15 PM
My database table has a FULLTEXT index for both col1 and col2.
When I do a match for either column by its self there is no problem.
However, when I try a match for both columns at the same time,
I get Error 1191: Can't find FULLTEXT index matching the column list.

SELECT *,
MATCH (col1, col2) AGAINST ('word1 word2')
AS score FROM tablename
WHERE MATCH (col1, col2) AGAINST ('+word1 +word2')
ORDER BY score DESCAny idea what could be wrong with the code?

Sam
;

Chris
05-24-2007, 03:16 PM
You need a fulltext index that is setup for both columns. 1 index, 2 columns.

NevadaSam
05-24-2007, 03:35 PM
When I CREATEd the table this is how I set up the indexes.
How should I set it up to search both columns?


FULLTEXT KEY `col1` (`col1`),
FULLTEXT KEY `col2` (`col2`)

rpanella
05-24-2007, 04:04 PM
When I CREATEd the table this is how I set up the indexes.
How should I set it up to search both columns?


FULLTEXT KEY `col1` (`col1`),
FULLTEXT KEY `col2` (`col2`)

Thats creating two separate indexes, one on each column. You will need to create another index on both of the columns.
________
FFM VIDS (http://www.****tube.com/categories/19/ffm/videos/1)

NevadaSam
05-24-2007, 04:10 PM
How should I set it up to search both columns?

Would I have to delete the existing indexes and make something like:
FULLTEXT KEY `col1` (`col1, col2`),

Chris
05-24-2007, 04:49 PM
exactly. I'm not sure about the exact syntax since I usually do such things in phpmyadmin, but that is the general gist of it.