错误1064:使用mysql workbench中的列和数字更新表

时间:2013-01-04 16:42:39

标签: mysql mysql-workbench

我需要update一个包含2值的表,其中一个是另一个表的列,第二个是数字(constant 1),这是我的代码:< / p>

insert into table (col1, col2)
select colA from table2, '1' 
 where DATA_FORMAT(table2.created_at, '%y %m %d') = DATA_FORMAT(Now(), '%y %m %d');

错误消息是:

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '1', '1'  where DATA_FORMAT(newsletter.created_at, '%y %m %d') = DATA_FORMA' at line 2

1 个答案:

答案 0 :(得分:0)

试试这个:

insert into table (col1, col2)
select colA, '1' as ColB from table2
where DATE_FORMAT(table2.created_at, '%y %m %d') = DATE_FORMAT(Now(), '%y %m %d');