[]内のMySQLデータベース演算子

  • 算術演算子
select 123 + 543, 321 * 5, -456 / 2, 10 % 3, 2 / 0, 3 % 0;
/* 输出:
+-----------+---------+-----------+--------+-------+-------
+
| 123 + 543 | 321 * 5 | -456 / 2 | 10 % 3 | 2 / 0 | 3 % 0
|
+-----------+---------+-----------+--------+-------+-------
+
|       666 |   1605 | -228.0000 |     1 | NULL | NULL
|
+-----------+---------+-----------+--------+-------+-------
+
1 row in set, 2 warnings (0.00 sec)
*/
  • 比較演算子
    ここに画像を挿入説明
select 1=2, 2<3, 3<=4, 4>5, 5>=3, 8!=9, 8<>9, 'abc' =
'Abc', 'z' > 'a';
/* 输出:
+-----+-----+------+-----+------+------+------+---------
------+-----------+
| 1=2 | 2<3 | 3<=4 | 4>5 | 5>=3 | 8!=9 | 8<>9 | 'abc' =
'Abc' | 'z' > 'a' |
+-----+-----+------+-----+------+------+------+---------
------+-----------+
|   0 |   1 |   1 |   0 |   1 |   1 |   1 |        
    1 |         1 |
+-----+-----+------+-----+------+------+------+---------
------+-----------+
1 row in set (0.00 sec)
*/
select 123 between 100 and 200, 'b' in ('a', 'b', 'c');
/* 输出
+-------------------------+------------------------+
| 123 between 100 and 200 | 'b' in ('a', 'b', 'c') |
+-------------------------+------------------------+
|                       1 |                     1 |
+-------------------------+------------------------+
1 row in set (0.04 sec)
*/
select 12 is null, 23 = null, null = null, null <=>
null, null is null, 32 is not null;
/* 输出
+------------+-----------+-------------+---------------
+--------------+----------------+
| 12 is null | 23 = null | null = null | null <=> null |
null is null | 32 is not null |
+------------+-----------+-------------+---------------
+--------------+----------------+
|         0 |     NULL |       NULL |             1 |
          1 |             1 |
+------------+-----------+-------------+---------------
+--------------+----------------+
1 row in set (0.00 sec)
*/
select 'HelloWorld' like 'hello%';
/* 输出
+----------------------------+
| 'HelloWorld' like 'hello%' |
+----------------------------+
|                         1 |
+----------------------------+
1 row in set (0.00 sec)
*/
  • 論理演算子
    ここに画像を挿入説明
公開された116元の記事 ウォン称賛10 ビュー1357

おすすめ

転載: blog.csdn.net/weixin_44727383/article/details/104979383