I have two tables with the same structure to get users finger print data and i want to get from the first table data that is not exist in the second table and insert it into the second table the structure of two tables:
我有两个具有相同结构的表来获取用户指纹数据,我想从第一个表中获取第二个表中不存在的数据,并将其插入第二个表中的两个表的结构:
- ID
- USER_ID
- check_time
- check_type
- sensor_id
1 个解决方案
#1
You can use insert into select from
using some additional join as
你可以使用insert来选择使用一些额外的join作为
insert into table2
select
t1.* from table1 t1
left join table2 t2 on t1.user_id = t2.user_id and t1.check_time = t2.check_time
where t2.user_id is null and t2.check_time is null
#1
You can use insert into select from
using some additional join as
你可以使用insert来选择使用一些额外的join作为
insert into table2
select
t1.* from table1 t1
left join table2 t2 on t1.user_id = t2.user_id and t1.check_time = t2.check_time
where t2.user_id is null and t2.check_time is null