Files
doris/docs/en/sql-manual/sql-functions/conditional-functions/if.md

1.3 KiB

title, language
title language
if en

if

description

Syntax

if(boolean condition, type valueTrue, type valueFalseOrNull)

Returns valueTrue when condition is true, returns valueFalseOrNull otherwise.

The return type is the type of the result of the valueTrue/valueFalseOrNull expression

example

mysql> select  user_id, if(user_id = 1, "true", "false") test_if from test;
+---------+---------+
| user_id | test_if |
+---------+---------+
| 1       | true    |
| 2       | false   |
+---------+---------+

keywords

IF