Skip to main content
October 13, 2013
Question

SQLLite case query

  • October 13, 2013
  • 1 reply
  • 466 views

Hi

How do you tell SQLLite to not change what's in the row if none of the case conditions are met?

'UPDATE table SET tag1=' +

                    'CASE ' +

                    'WHEN tag1="Blah" THEN "Blah new" ' +

                    'WHEN tag1="Blah2" THEN "Blah2 new" ' +

                  

                    'ELSE tag1=tag1 ' +

                    'END';// +

'ELSE tag1=tag1 ' inserts the number 1 into all ELSE columns, and leaving that line out altogether empties whatevers in that column.

Cheers guys

This topic has been closed for replies.

1 reply

October 13, 2013

Never mind

You can have END, but then need to have...

'WHERE tag1 IN ("Blah", "Blah2")';

...after it to tell SQLLite to ONLY affect those records, otherwise is seems to delete all other records for that column that aren't dealt with in the CASE conditions.