> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# if

> 若参数 expr1 成立，返回 expr2，否则返回 expr3。

若参数 `expr1` 成立，返回结果 `expr2`，否则返回结果 `expr3`。

## 语法

```Haskell theme={null}
if(expr1,expr2,expr3);
```

## 参数说明

`expr1`: 支持的数据类型为 BOOLEAN。

`expr2` 和 `expr3` 必须在数据类型上能够兼容，否则返回报错。

## 返回值说明

返回值的数据类型与 `expr2` 类型一致。

## 示例

```Plain Text theme={null}
mysql> select if(false,1,2);
+-----------------+
| if(FALSE, 1, 2) |
+-----------------+
|               2 |
+-----------------+

mysql> select if(false,2.14,2);
+--------------------+
| if(FALSE, 2.14, 2) |
+--------------------+
|               2.00 |
+--------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.