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

Code Example 1

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

Learn ReactJs, React Native from akashmittal.com