Reputation: 59
My code snippet:
UPDATE "LookUpWrkflwTemp" SET SpiralUniverse = (
SELECT Count (*)
FROM SpiralUniverse
WHERE Date = '2015-11-16') WHERE Date = '2015-11-16';
My goal is to find a Date value where the other fields in the row are null and pass that value to the above WHERE clause.
Sample data:
"SpiralUniverse"
rowid Date Symbol
1 2015-11-16 ACOR
2 2015-11-16 AAPL
3 2015-11-16 TSLA
4 2015-11-10 TSLA
"LookUpWrkflwTemp"
rowid Date SpiralUniverse
1 2015-11-10 1
2 2015-11-16 NULL
After UPDATE the result should be:
"LookUpWrkflwTemp"
rowid Date SpiralUniverse
1 2015-11-10 1
2 2015-11-16 3
There will only be one record in the above table where there is a date value and the other field values are null.
Upvotes: 1
Views: 40
Reputation: 1269973
I think you just need a correlated subquery:
UPDATE LookUpWrkflwTemp
SET SpiralUniverse = (SELECT Count(*)
FROM SpiralUniverse su
WHERE su.Date = LookUpWrkflwTemp.Date
)
WHERE SprialUniverse IS NULL;
Upvotes: 1