0

我需要update一个带有2值的表,其中一个是另一个表的列,第二个是数字(constant 1),这是我的代码:

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
4

1 回答 1

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');
于 2013-01-04T16:45:10.283 回答