[英]How to use a sub-query as value for inserting?
我有這樣的查詢:
INSERT INTO table1(col1,col2,col4)
VALUES (1, (select col1 from table2 where col2 = :param), 1);
以上查詢也有效。 現在我想使用table2
兩列,如下所示:
INSERT INTO table1(col1,col2,col3,col4)
VALUES (1, (select col1,col2 from table2 where col2 = :param), 1);
但第二個查詢不起作用,我該如何解決?
INSERT INTO table1(col1, col2, col3, col4)
select 1, col1, col2, 1
from table2
where col2 = :param;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.