# 布尔表达式

__*布尔表达式*__

+ TiDB 考虑:
  + 常量名称:以任何字母大小写表述 **TRUE** 和 **FALSE** 
    + **TRUE** 的结果为 **1**
    + **FALSE** 的结果为 **0**
+ **BOOLEAN** 数据类型实际上被定义为 `TINYINT (1)`
+ 例如: 
  + `select 1=true, 1=TRUE, true;`
```
tidb> SELECT 1=true, 1=TRUE, true;
+--------+--------+------+
| 1=true | 1=TRUE | TRUE |
+--------+--------+------+
|      1 |      1 |    1 |
+--------+--------+------+
1 row in set (0.00 sec)
```
----------------------------------------------------------------
```
tidb> create table test.bgl (id boolean);
Query OK, 0 rows affected (0.10 sec)

tidb> desc test.bgl;
+-------+------------+------+------+---------+-------+
| Field | Type       | Null | Key  | Default | Extra |
+-------+------------+------+------+---------+-------+
| id    | tinyint(1) | YES  |      | NULL    |       |
+-------+------------+------+------+---------+-------+
1 row in set (0.00 sec)

tidb> insert into test.bgl values (true), (false), (123);
Query OK, 3 rows affected (0.02 sec)
Records: 3 Duplicates: 0 Warnings: 0

tidb> select * from test.bgl;
+------+
| id   |
+------+
| 1    |
| 0    |
| 123  |
+------+
3 rows in set (0.00 sec)
```

