简体   繁体   English

mysql语句SELECT INSERT INTO提示

[英]mysql statment SELECT INSERT INTO tip

My statement is correct missing one Column, but it does not insert the hashtag from table trending_topics into the rss table based on order. 我的陈述是正确的,它缺少一列,但它不会根据顺序将来自表trending_topics的主题标签插入到rss表中。

Any adjust can help me with my statement. 任何调整都可以帮助我进行陈述。

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;;

My insert into table ( rss ) looks like: 我插入表( rss )如下所示:

  id  hashtag  total
  1    null    55
  2    null    22

If the datatypes and your example sql etc. are correct (and there is a hashtag returned by the select) then the following should work ( remove the id in the insert into statement) 如果数据类型和示例sql等正确(并且select返回了井号),则应执行以下操作( 删除 insert into语句中的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;

The number of inserted fields should match the number of fields specified at INSERT INTO table_name (field list) 插入的字段数应与INSERT INTO table_name (field list)指定的字段数匹配

INSERT INTO rss (hashtag,total)
SELECT
  hashtag,
  SUM(count) AS total

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM