0

我的声明是正确的,缺少一列,但它不会根据顺序trending_topics将表中的主题标签插入表中。rss

任何调整都可以帮助我完成我的陈述。

INSERT INTO rss (id,hashtag,total)
SELECT
  hashtag,
  SUM(count) AS total
FROM `trending_topics`
WHERE lang=0
  AND hashtag !=     ''
  AND date >= date_sub(left(now(), 10), interval 1 day)
GROUP BY hashtag order by total desc;;

我插入表 ( rss) 看起来像:

  id  hashtag  total
  1    null    55
  2    null    22
4

2 回答 2

2

如果数据类型和您的示例 sql 等是正确的(并且选择返回了一个主题标签),那么以下应该有效(删除插入语句中的 id )

INSERT INTO rss (hashtag,total)
SELECT
  hashtag,
  SUM(count) AS total
FROM `trending_topics`
WHERE lang=0
  AND hashtag !=     ''
  AND date >= date_sub(left(now(), 10), interval 1 day)
GROUP BY hashtag order by total desc;
于 2012-07-15T09:58:00.640 回答
1

插入的字段数应与指定的字段数相匹配INSERT INTO table_name (field list)

INSERT INTO rss (hashtag,total)
SELECT
  hashtag,
  SUM(count) AS total
于 2012-07-15T09:32:14.737 回答