从内部联接中选择匹配返回0结果的位置

时间:2012-04-28 18:23:35

标签: mysql full-text-search inner-join

table.a是innodb有字段id,post_id,auther,add_date

table.b是myisam有字段post_id,title,content,全文密钥(标题,内容)

select * from b 
where match (title,content) 
against ('+words' in boolean mode)

这可能会返回12条记录。当运行解释时,我可以看到全文密钥。但是

select * from a 
inner join b 
on a.post_id = 'b.post_id' 
where match (b.title,b.content)
against ('+words' in boolean mode)
and a.auther = 'someone'
order by a.id asc

这个后退0的结果。我已经检查了

select id,auther,post_id from a where auther = 'someone' 

返回post_id放入mysql

select post_id from b where post_id = 'post_id from table a'

这个结果是存在的。那问题出在哪里? (顺便说一下,2个表post_id都保存为varchar)

1 个答案:

答案 0 :(得分:0)

我怀疑您不打算将连接条件设为

on a.post_id = 'b.post_id'

而是

on a.post_id = b.post_id

(不同之处在于您的版本会将b的每一行加入a的任何行,其中a.post_id是字符串"b.post_id",而我的版本会加入行ab,其各自的post_id列相等。