mysql 多表搜索_MySQL:如何进行多表全文搜索

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-28 18:48   35   0

bd96500e110b49cbb3cd949968f18be7.png

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');

解决方案

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'

);

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP