0
[URGENT] SQL - Update statement with two if condition
Hi. How do i update a column in table, that if it met a select statement, then it will updated to '1'. Else, it will updated to '0'. I tried this: If exist(select statement) Begin Execute(update statement to '1') End Else Begin Execute(update statement to '0') End But this query will only update to '1', and ignore the update statement to '0. Any idea?
2 Respuestas
+ 3
UPDATE tablename
SET columnname =
CASE
WHEN (select statement) THEN 1
ELSE 0
END
+ 1
Calviղ it's working. Thanks a lot!!