我有一个像这样的关键字表:
CREATE TABLE `keywords` (
`keyword` VarChar( 48 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`id` Int( 11 ) AUTO_INCREMENT NOT NULL,
`blog_posts_fulltext_count` Int( 11 ) NOT NULL,
PRIMARY KEY ( `id` ) )
我还有一张博客帖子表格,如下所示:
CREATE TABLE `blog_posts` (
`id` Int( 11 ) AUTO_INCREMENT NOT NULL,
`title` LongText CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
`summary` LongText CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
PRIMARY KEY ( `id` ) );
CREATE FULLTEXT INDEX `title_summary_fulltext` ON `blog_posts`( `title`, `summary` );
如您所见,我在title
中的summary
,blog_posts
字段上有一个全文索引。
以下搜索正确运行:
select count(*) from blog_posts where match(title,summary) against ('paid');
现在,我想用keywords.blog_posts_fulltext_count
出现在blog_posts
中的行数填充字段keyword
。
运行此命令时:
UPDATE
keywords k
SET
k.blog_posts_count = (select count(*)
from blog_posts where match(title,summary)
against (keyword));
...我得到:
“再次使用不正确的参数”
如果我这样运行它,我会得到相同的错误:
UPDATE
keywords k
SET
k.blog_posts_count = (select count(*)
from blog_posts where match(title,summary)
against (k.keyword)); -- <== "k" used to specify the table field `keyword` comes from
我想念什么?