3

I want to integrate the MySQL fulltext search function in my PHP site.

I have the following problem now.

SELECT *
FROM testtable t1, testtable2 t2
WHERE MATCH (
t1.firstName, t1.lastName, t1.details, t2.firstName, t2.lastName, t2.details
)
AGAINST (
'founder'
);

And i have the error code:

#1210 - Incorrect arguments to MATCH

Do you know why and how to solve it?

Thanks very much!

Edit:

I adopt RageZ's method:

SELECT *
FROM testtable t1, testtable2 t2
WHERE MATCH (
t1.firstName, t1.lastName, t1.details
)
AGAINST (
'founder'
) OR MATCH( t2.firstName, t2.lastName, t2.details) AGAINST (
'founder'
); 

And I have a new question. If i want to find the content which are :

AGAINST('founder', 'initiator', 'employee');

How to write the query?

Ok, i know against can only have one criteria.

AGAINST('founder');
SUN Jiangong
  • 5,242
  • 16
  • 57
  • 76

2 Answers2

3

I think since full text search use some specific indexes you should separate table by OR

SELECT *
FROM testtable t1, testtable2 t2
WHERE MATCH (
t1.firstName, t1.lastName, t1.details
)
AGAINST (
'founder'
) OR MATCH( t2.firstName, t2.lastName, t2.details) AGAINST (
'founder'
); 
RageZ
  • 26,800
  • 12
  • 67
  • 76
  • that smells like a cartesian product to me (but then, I have no experience with "match / against") .. shouldn't there be a "restriction" (aka join) that provents this? – lexu Mar 04 '10 at 10:23
  • @thanks RageZ, if the elements in AGAINST are multiple, how to handle that? – SUN Jiangong Mar 04 '10 at 10:27
  • your would have to copy the pattern multiple time – RageZ Mar 04 '10 at 10:58
  • @lexu: the error message is specific about the syntax in the against not being correct. if mysql would have ran crazy I would have bet like you ;-) – RageZ Mar 04 '10 at 11:00
0
AGAINST('founder initiator employee');

or you can use boolean mode with more good stuff

JMax
  • 26,109
  • 12
  • 69
  • 88