简体   繁体   中英

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. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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