INSERT INTO courses1 (sys_id,name, location)
SELECT *
FROM courses
WHERE sys_id= $sysid
I have the two tables above and I want to insert in course1 what I have in course. But I get problem with sys_id
because I get Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'' in
so what I did is a added a column in courses1 named system_id
but then I get another error saying column not match.
Tried
INSERT IGNORE INTO
but ther result is not what I am expecting. The result I want is to have the data from course to course1 everytime I make a transaction. I want the data not to be overriden.
- What is the best solution for
insert into
when inserting same row(same primary key)?
UPDATE
My aim is to back-up the data (historical data). I want to record the data before editing it. basically what i am doing is inserting the data in another table before updating it