Update with a sub-query

Hi, I’m trying a query to perform an update from a sub-query, but it gives me an error.
The query is as follows:

WITH up AS (select index_time, ColA, ColB from MyTabTmp)
UPDATE MyTab mt
SET mt.ColA = up.ColA, mt.ColB = up.ColB
FROM up WHERE mt.index_time=up.index_time;

‘=’ expected


I get the same error with your query, see example at the link:

WITH up AS (
SELECT p.ask - p.bid AS spread, s.timestamp
FROM prices p
JOIN instruments i ON p.symbol = i.symbol
WHERE i.type = ‘BOND’
)
UPDATE spreads s
SET s.spread = up.spread
FROM up
WHERE s.timestamp = up.timestamp;

Hey @BepTheWolf , we’ll look into this and come back to you!

1 Like

Indeed, this looks like a parsing bug, where the parser does not handle the . properly. We’ll fix it!

1 Like