简体   繁体   English

插入时混合参数化查询和子查询

[英]Mixing Parameterized Query and Sub-query on Insert

I have a colleague who wants to attempt the following query: 我有一个同事想尝试以下查询:

INSERT INTO table (ColumnA, ColumnB, ColumnC)
VALUES (?, (SELECT Id FROM ColumnD WHERE x=y), ?)

Sybase complains about this as it does not seem to allow subqueries in the VALUES portion of the query. Sybase抱怨这一点,因为它似乎不允许查询的VALUES部分中的子查询。 Does anyone know of a way around this problem? 有谁知道解决这个问题的方法吗?

How about: 怎么样:

INSERT INTO table (ColumnA, ColumnB, ColumnC)
SELECT
  ?,
  Id,
  ?
FROM
  TableD
WHERE
  x = y

(Or similar) (或类似)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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