我试图在一个查询中使用insert和select。除了表中要插入数据的一列之外,表中的列数相同
table2
是table1
的镜像,除了名为comments的列;
insert into table2 select * from table1 where city='XYZ' and name = 'STY'
由于列数不相等,我得到以下错误:
列数与第1行的值计数不匹配
答案 0 :(得分:0)
INSERT INTO table2 (Coln1,Coln2,Coln3,....) SELECT * FROM table1 WHERE `city`='XYZ' AND `name`='STY';
对于table2中的额外列,默认设置为NULL。