如何嵌套Select语句

时间:2018-02-07 03:07:16

标签: sql-server

我选择了这样:

compileKotlin2Js.kotlinOptions.outputFile = "out/output.js"

我想获取此值并将其用作insert

中的寄存器

我试试:

  SELECT UserName FROM Users WHERE userId= @UserId;

但是我的列无效,这样做的正确方法是什么?

2 个答案:

答案 0 :(得分:0)

您的语法不正确。正确的方法在VALUES

中没有INSERT INTO...SELECT个关键字
INSERT INTO Product.ProductDetail (ColumnName) -- Must specify target column if you have multiple columns in the table
SELECT UserName 
FROM Users 
WHERE userId= @UserId

答案 1 :(得分:0)

INSERT INTO Product.ProductDetail (UserName) SELECT UserName FROM Users WHERE userId= @UserId

如果要在表中插入自动增量键,则需要特定的插入列名称。

相关问题