美文网首页
mysql同表批量增加数据

mysql同表批量增加数据

作者: Yluozi | 来源:发表于2020-11-18 19:05 被阅读0次

自增字段无视



insert into resource_field_match_mapp 
(
resource_id,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
remarks,
status,
resource_name,
datatype_title,
dataaction_title

) 
select 
16,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
remarks,
status,
'学术辑刊',
datatype_title,
dataaction_title
from resource_field_match_mapp where resource_id=20


---查询两个表内的差异数据

select a.* from ( select * from  kweb_product.`product_field_entity_mapp`)  as  a   where not exists (select 1 from (select  * from  oldku.`product_field_entity_mapp`)   as  b  where b.product_entity_id=a.product_entity_id and a.dbfield=b.dbfield);



---添加两个表内的差的数据


insert into kweb_product.`product_field_entity_mapp`
(
product_entity_id,
table_id,
entity_id,
resource_id,
datatype_id,
dbfield,
dbfield_alias,
entity_name,
ismark,
islazy,
remarks,
`status` 
) 

select  
product_entity_id,
table_id,
entity_id,
resource_id,
datatype_id,
dbfield,
dbfield_alias,
entity_name,
ismark,
islazy,
remarks,
`status` 
 from   oldku.`product_field_entity_mapp` where product_entity_id > 19627

---查询两个表内的差异数据

select a.* from ( select * from  kweb_product.`resource_field_match_mapp`)  as  a   where not exists (select 1 from (select  * from  oldku.`resource_field_match_mapp`)   as  b  where b.match_id=a.match_id and a.field=b.field and  a.field_key= b.field_key );



---添加两个表内的差的数据


insert into kweb_product.`resource_field_match_mapp`
(
match_id,
resource_id,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
remarks,
`status`,
resource_name,
datatype_title,
dataaction_title
) 

select  
match_id,
resource_id,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
remarks,
`status`,
resource_name,
datatype_title,
dataaction_title
 from   oldku.`resource_field_match_mapp` where match_id > 1310

---查询两个表内的差异数据

select a.* from ( select * from  kweb_product.`product_field_match_mapp`)  as  a   where not exists (select 1 from (select  * from  oldku.`product_field_match_mapp`)   as  b  where b.id=a.id and a.field=b.field and  a.field_key= b.field_key );



select a.* from ( select * from  oldku.`product_field_match_mapp`)  as  a   where not exists (select 1 from (select  * from  kweb_product.`product_field_match_mapp`)   as  b  where b.id=a.id and a.field=b.field and  a.field_key= b.field_key );

---添加两个表内的差的数据


insert into kweb_product.`product_field_match_mapp`
(
id,
table_id,
match_id,
resource_id,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
sort_id,
remarks,
`status`,
fuzzy
) 

select  
id,
table_id,
match_id,
resource_id,
datatype_id,
dataaction_id,
field_key,
field,
alias,
displayname,
field_match,
operator,
dictionary,
top,
max,
sort_id,
remarks,
`status`,
fuzzy
 from   oldku.`product_field_match_mapp` where id > 22510

相关文章

网友评论

      本文标题:mysql同表批量增加数据

      本文链接:https://www.haomeiwen.com/subject/jmthiktx.html