SQL has an IF/ELSE statement that allows you to do something if a condition is true, and something else if it’s not.

Here’s how it works:

IF condition THEN
statement1
ELSE
statement2
END IF;

For example, let’s say we have a table of employees, and we want to give a 10% raise to those who have been with the company for more than 5 years, and a 5% raise to everyone else. We could use the following SQL:

UPDATE employees SET salary = salary * 1.1 WHERE years_employed > 5;
UPDATE employees SET salary = salary * 1.05 WHERE years_employed <= 5;