tags:

views:

112

answers:

1

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?

+2  A: 

How about:

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

(Or similar)

jerryjvl