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

时间:2022-10-26 20:13:25

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. Does anyone know of a way around this problem?

Sybase抱怨这一点,因为它似乎不允许查询的VALUES部分中的子查询。有没有人知道解决这个问题的方法?

1 个解决方案

#1


How about:

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

(Or similar)

#1


How about:

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

(Or similar)