how to write if condition in where in sql query code example Example: if in sql SELECT IF(500<1000, "YES", "NO");