Filipe Tagliacozzi
Filipe Tagliacozzi

Reputation: 1431

How to insert into a table data and select from another table?

I want to do something like this:

My tb_b:
---------------
   B   |   C     // Columns
---------------
  'y'  |  'z'    // row
---------------

EX: INSERT INTO tb_a(a,b,c) VALUES ('x',SELECT * from tb_b)

I want this result:

My tb_a:
-----------------
 A  |   B   |   C     // Columns
-----------------
'x' |  'y'  |  'z'    // row
-----------------

How to Insert into table a data and selected rows from tb_b?

Upvotes: 3

Views: 219

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191819

INSERT INTO tb_a (a, b, c)
SELECT 'x', tb_b.B, tb_b.C FROM tb_b

Upvotes: 4

Related Questions