在mysql中使用搜索文本索引时出错


Error when using search text index in mysql

我有一个使用全文的2表

test1(id, name1, description1)
test2(id, name2, description2, test1_id)

和一个查询

Select a.name1, b.name2 From test1 as a, test2 as b 
Where a.id = b.test_1id 
And MATCH(a.name1, a.description1, b.name2, b.desciption2) AGAINST ("%searchstring%")

结果是mysql无法运行,我认为MATCH (...,b.name2, b.desciption2)中有错误,如何修复?非常感谢。

我认为您在where条件中有一个错误:

其中a.id=b.test_1.id(b是表test2的别名,但字段名不应包含点)

将其更改为正确的字段名称,它应该会起作用。

不是AGAINST ("%searchstring%")应该是AGAINST ('%searchstring%')

用单引号替换双引号。。。

以下是通常使用的查询

SELECT * FROM articles
WHERE MATCH(title, body) AGAINST ('PHP')

更新1

我看到你在Where a.id = b.test_1id 有问题

我认为Where a.id = b.test_1id应该是Where a.id = b.test1_id

在您的查询中,您有test_1id而不是test1_id。检查这是否是您的问题。。。

祝你好运!!!