Using insert into … select results in a incorrect syntax near select, why?

后端 未结 6 1084
时光取名叫无心
时光取名叫无心 2021-02-05 02:46

How can I make a SELECT inside an INSERT operation?

insert into tableX (a_id, b_id) 
VALUES ((SELECT service_id 
         FROM tableY 
         WHERE id = 10, 2))         


        
6条回答
  •  长情又很酷
    2021-02-05 03:01

    You're telling the DBMS that you're inserting two values (a_id, b_id) but only selecting one (service_id).

提交回复
热议问题