Skip to content
Advertisement

Have multiple parameters in a WHEN part of a SQL Update Statement

I need to write a sql update statement without repeating the parameter on the WHEN part of the query, below query works fine however I would like to group the related parameters together, this is how the current query looks like

for example I would like to use an IN to group bundle all the STCs belong to 40 together, I have tried the below part, but no joy

WHEN IN ('841000','841005','841004') THEN 40

Advertisement

Answer

You can move the conditions from the case to the when part of the expression:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement