Check out example codes for "if statement in sql". It will help you in understanding the concepts better.

Code Example 1

SELECT SUM(IF(user.name LIKE '%bob%',1,0)) AS `total_bobs`,

Code Example 2

IF Boolean_expression
BEGIN
    -- Statement block executes when the Boolean expression is TRUE
END
ELSE
BEGIN
    -- Statement block executes when the Boolean expression is FALSE
END

Code Example 3

--Single line if statement
if RTRIM('t') = 't'
	SELECT 'equal to t'
    
--Single line if ... else
if RTRIM('b') = 't'
	SELECT 'equal to t'
else
	SELECT 'not equal to t'
    
-- if you need to exexute multiple lines, use BEGIN...END block
if RTRIM('T') = 't'
	BEGIN
		Select 'equal to t'
		Select 'and another select'
	END

Code Example 4

SELECT IF(1>3,'true','false');

Learn ReactJs, React Native from akashmittal.com