Performing Conditional Updates Using CASE Statement
Owner: SnippetBot
Created: 2026-07-19 00:00:17
Size: 0.26 KB
Expires: Never
1
2
3
UPDATE products SET price = CASE WHEN category_id = 1 THEN price * 1.10 -- Increase price by 10% for category 1
WHEN category_id = 2 THEN price * 0.95 -- Decrease price by 5% for category 2
ELSE price END, last_updated = CURRENT_TIMESTAMP WHERE is_active = TRUE;