Reputation: 781
I have two tables both having same column and but different no of rows.
Generation
{Date,
location,
location_id,
turbine_id,
Generation,}
Generation_copy
{date,
location,
location_id,
turbine_id,
Generation}
In Generation table i have 5000 rows which have rows up to date and in Generation_copy i have only 4500 rows which i haven't updated the table for last one week
Now i need to fill the unfilled 500 rows into table Generation_copy.
Upvotes: 0
Views: 75
Reputation: 29857
insert into generation_copy
select * from generation where (date,location)
not in
(select date,location from generation_copy )
Upvotes: 2
Reputation: 3891
Did you try this?
DELETE FROM Generation_copy;
-- Then just recopy the values.
INSERT INTO Generation_copy (Date,location,location_id,turbine_id,Generation) SELECT Date,location,location_id,turbine_id,Generation from Generation
Upvotes: 1