if value sql in where 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: if in sql
SELECT
IF(500<1000, "YES", "NO");