where if condition in sql code example
Example 1: if in sql
-- PL/SQL
BEGIN
IF my_val = 1 THEN [...]
ELSE [...]
END IF;
END;
-- In a query (DUAL is for Oracle)
SELECT CASE WHEN my_col = 1 THEN 'Ok' ELSE 'Ko' END AS my_result
FROM DUAL;
Example 2: what is in condition in sql
IN condition allows you to easily test
if an expression matches any value in a list of values.
It is for reducing multiple OR
conditions in a SELECT, INSERT,
UPDATE, or DELETE statement.