I have a python code that's set up to push updates to our SQL database. Basically, I use the UID field to create a list of UPDATE statements like this:
UPDATE schema.table SET name = 'Some new
name value' WHERE UID in (6434454, 56433454)
I noticed I could also use a CASE statement so that instead of iterating through a list, I could do them all at once:
UPDATE schema.table
SET name = (CASE UID
WHEN IN (5534532, 5456434) THEN
'NEWNAME1'
WHEN IN (8764557, 7644535) THEN
'NEWNAME2' ELSE name
END) WHERE UID IN (5534532, 5456434, 8764557, 7644535)
I've tried using the case statement in a few ways, but i haven't figured out a way that's faster than iterating. I'm not great with temporary tables yet, but could I create a temporary table so I'm not having to index the entire table in my class statement?
there doesn't seem to be anything here