mysql> SELECT 10 BETWEEN 10 AND 20, 9 BETWEEN 10 AND 20;+----------------------+---------------------+| 10 BETWEEN 10 AND 20 | 9 BETWEEN 10 AND 20 |+----------------------+---------------------+| 1 | 0 |+----------------------+---------------------+
mysql> SELECT 'abcdef' regexp 'ab', 'abcdefg' regexp 'k';+----------------------+----------------------+| 'abcdef' regexp 'ab' | 'abcdefg' regexp 'k' |+----------------------+----------------------+| 1 | 0 |+----------------------+----------------------+
MySQL中包含的逻辑运算符:
分别对几种逻辑运算符进行描述:
mysql> SELECT NOT 0, NOT 1 , NOT NULL;+-------+-------+----------+| NOT 0 | NOT 1 | NOT NULL |+-------+-------+----------+| 1 | 0 | NULL |+-------+-------+----------+
mysql> SELECT 1 AND 1, 0 AND 1, 3 AND 1, 1 AND NULL;+---------+---------+---------+------------+| 1 AND 1 | 0 AND 1 | 3 AND 1 | 1 AND NULL |+---------+---------+---------+------------+| 1 | 0 | 1 | NULL |+---------+---------+---------+------------+
mysql> SELECT 1 OR 0, 0 OR 0, 1 OR NULL, 1 OR 1, NULL OR NULL;+--------+--------+-----------+--------+--------------+| 1 OR 0 | 0 OR 0 | 1 OR NULL | 1 OR 1 | NULL OR NULL |+--------+--------+-----------+--------+--------------+| 1 | 0 | 1 | 1 | NULL |+--------+--------+-----------+--------+--------------+
mysql> SELECT 1 XOR 1, 0 XOR 0, 1 XOR 0, 0 XOR 1, NULL XOR 1;+---------+---------+---------+---------+------------+| 1 XOR 1 | 0 XOR 0 | 1 XOR 0 | 0 XOR 1 | NULL XOR 1 |+---------+---------+---------+---------+------------+| 0 | 0 | 1 | 1 | NULL |+---------+---------+---------+---------+------------+
MySQL5.0支持的位运算符:
分别介绍这几种位运算:
mysql> SELECT 2&3, 2&3&4;+-----+-------+| 2&3 | 2&3&4 |+-----+-------+| 2 | 0 |+-----+-------+
mysql> SELECT 2|3, 2|3|4;+-----+-------+| 2|3 | 2|3|4 |+-----+-------+| 3 | 7 |+-----+-------+
mysql> SELECT 2^3;+-----+| 2^3 |+-----+| 1 |+-----+
mysql> SELECT ~1, ~18446744073709551614;+----------------------+-----------------------+| ~1 | ~18446744073709551614 |+----------------------+-----------------------+| 18446744073709551614 | 1 |+----------------------+-----------------------+
mysql> SELECT 100>>3;+--------+| 100>>3 |+--------+| 12 |+--------+
mysql> SELECT 100<<3;+--------+| 100<<3 |+--------+| 800 |+--------+
具体的运算符的细节可参考官网:
http://dev.mysql.com/doc/refman/5.7/en/non-typed-operators.html
不吝指正。