我们可以在 2 个表的连接上使用全文索引搜索吗? 这是我的查询:
select DISTINCT table1.email from table1
LEFT JOIN table2 ON table1.email = table2.email
where MATCH(name,city,area,landmark,class,subject)
AGAINST('some text to search from');
最佳答案
假设 class
和 subject
来自 table2
,使用:
WHERE IF(table2.email IS NULL,
MATCH(name, city, area, landmark) AGAINST ('some text to search from'),
MATCH(name, city, area, landmark, class, subject) AGAINST ('some text to search from'))
这样,当行中没有来自该表的数据时,它不会尝试从 table2
中搜索列。
关于mysql - 2 个表的连接中的 FULLTEXT 索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31634838/