I have two tables with the following structure :
userid, entrydatetime, record.
tableA – has primary key (userid, entrydatetime)
tableB – has no constraints set.
I am trying to do an
INSERT INTO tableA SELECT * FROM tableB ,
but I am getting an error because tableB has all the same userid and entrydatetime.
e.g. userid = ‘12345’ and entrydatetime = ‘0000-00-00 00:00:00’.
the main data that I need from tableB are userid and record. entryDateTime is less critical to me for this scenario.
How can I merge my two tables yet keeping my tableA primary key constraint? Is there a way I can randomize or autoincrement the entrydatetime field on insert?
You can use following query
Hope it helps…