I have a query that takes all data from database A and inserts it into database B. It is working correctly, however I created a new column in database B called “actual_date” and I would like that, when inserting the data in database B, also insert the current date when these values were entered in database B.
Something like:
INSERT INTO databaseB(col1, col2, actual_date) SELECT databaseA.col1, databaseA.col2, CURRENT_TIMESTAMP FROM databaseA
Obviously the above query is wrong, but it would be something like this, because in database A, there is no column with the current date.
Is this possible?
Advertisement
Answer
Use Date():
INSERT INTO databaseB (col1, col2, actual_date) SELECT databaseA.col1, databaseA.col2, Date() FROM databaseA