两个表结构相同,第一个字段id是自增唯一的,因此不在搬运的字段列表里,其他字段都要复制过去。
先试了:
insert into leather_shoes_attachment_log(parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
select (parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
from leather_shoes_attachment
where object_id ='MODULE_ATTACHMENT_20181102172032'
===================
系统提示:
[SQL]insert into leather_shoes_attachment_log(parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
select (parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
from leather_shoes_attachment
where object_id ='MODULE_ATTACHMENT_20181102172032'
[Err] 1241 - Operand should contain 1 column(s)
===================
然后去掉select 后头的小括号:
insert into leather_shoes_attachment_log
(parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
select parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time
from leather_shoes_attachment
where object_id ='MODULE_ATTACHMENT_20181102172032';
===================
就对了。
[SQL]insert into leather_shoes_attachment_log
(parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time)
select parent_id,object_id,attachment_filename,attachment_name,attachment_url,attachment_type,creator,create_time
from leather_shoes_attachment
where object_id ='MODULE_ATTACHMENT_20181102172032';
受影响的行: 1
时间: 0.003s