Can a row be inserted from one table to another?


#1

Question

Can a row be inserted from one table to another?

Answer

Yes, it is possible, we could instead of using VALUES we SELECT from another table and pass what we get as values, for example:

INSERT INTO jokes [( title,  text_bit, author)]
SELECT title, text_bit, author FROM famous_jokes
WHERE author = 'Jim Carrey' OR author = 'Trevor Noah';

Usually, an insertion like this is uncommon, usually, we will be better of making a join query to get a result, but if necessary it is not impossible as we can see.