Reputation: 3731
I'm having two tables table
(fieldA, fieldB, fieldC) and log_table
(id, fieldA, fieldB, fieldC). Is it possible to copy a row from table
to log_table
with one (not two: select and insert) query?
Thank you in advance!
Upvotes: 0
Views: 214
Reputation: 8578
You can use a single INSERT statement passing a SELECT query instead of a list of constant values:
INSERT INTO log_table (SELECT fieldA, fieldB, fieldC FROM table)
Upvotes: 3
Reputation: 31249
I am not sure what you want. But maybe something like this:
INSERT INTO log_table( fieldA, fieldB, fieldC)
SELECT fieldA, fieldB, fieldC FROM table
Upvotes: 1