代码实现:
mysql> select name,id,sex 性别 from stu where id != 1; +--------+------+------+ | name | id | 性别 | +--------+------+------+ | 小程 | 2 | 男 | | 哈哈哈 | 3 | 男 | | hhh | 4 | 女 | | wuwuwu | 5 | 女 | +--------+------+------+ 4 rows in set (0.00 sec) mysql> select * from stu where id<3 and name like "小%"; +------+------+------+ | name | id | sex | +------+------+------+ | 小爽 | 1 | 女 | | 小程 | 2 | 男 | +------+------+------+ 2 rows in set (0.00 sec) mysql> insert into stu values("aaaa",null,"女"); Query OK, 1 row affected (0.01 sec) mysql> select * from stu where id is null; +------+------+------+ | name | id | sex | +------+------+------+ | aaaa | NULL | 女 | +------+------+------+ 1 row in set (0.01 sec) mysql> select * from stu where id is not null; +--------+------+------+ | name | id | sex | +--------+------+------+ | xue | 1 | 男 | | 小爽 | 1 | 女 | | 小程 | 2 | 男 | | 哈哈哈 | 3 | 男 | | hhh | 4 | 女 | | wuwuwu | 5 | 女 | +--------+------+------+ 6 rows in set (0.00 sec) mysql> select * from stu where id in (3,4,5); +--------+------+------+ | name | id | sex | +--------+------+------+ | 哈哈哈 | 3 | 男 | | hhh | 4 | 女 | | wuwuwu | 5 | 女 | +--------+------+------+ 3 rows in set (0.00 sec)
代码实现:
mysql> select * from stu order by id desc; +--------+------+------+ | name | id | sex | +--------+------+------+ | wuwuwu | 5 | 女 | | hhh | 4 | 女 | | 哈哈哈 | 3 | 男 | | 小程 | 2 | 男 | | xue | 1 | 男 | | 小爽 | 1 | 女 | | aaaa | NULL | 女 | +--------+------+------+ 7 rows in set (0.01 sec)