我有一个无法运行的SQL代码:
INSERT INTO t_ruleid(logdate,month,hour,ruleid,Hits,Host,cdn_id) select b.logdate,b.month,b.hour,b.ruleid,b.Hits,b.Host,b.cdn_id from t_ruleid_back as b ON DUPLICATE KEY UPDATE Hits=Hits+b.Hits;
它出错了列' Hits'在字段列表中是不明确的
我怎样才能让它发挥作用?
谢谢!
答案 0 :(得分:0)
通常,您可以使用values()
来获取传入内容的值:
insert into t_ruleid(logdate, month, hour, ruleid, Hits, Host, cdn_id)
select b.logdate, b.month, b.hour, b.ruleid, b.Hits, b.Host, b.cdn_id
from t_ruleid_back as b
on duplicate key update Hits = Hits + values(Hits);
我不确定b.Hits
会产生那个特定的错误。