简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM