dimanche 3 janvier 2016

SQLite - How to pass a field value to a WHERE clause

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.

Aucun commentaire:

Enregistrer un commentaire