MySQL学习笔记六
文章目录
一、简介
时隔多日没有学习MySQL数据库了,今天重新开始继续学习MySQL数据库的有关内容,并重新开启MySQL的新的征程。
二、MySQL NULL 值处理
MySQL NULL 值处理
root@host# mysql -u root -p password;
Enter password:*******
mysql> use RUNOOB;
Database changed
mysql> create table runoob_test_tbl
->(-> runoob_author varchar(40) NOT NULL,-> runoob_count INT
->);
Query OK,0 rows affected (0.05 sec)
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('RUNOOB',20);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('菜鸟教程', NULL);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('Google', NULL);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('FK',20);
mysql> SELECT *from runoob_test_tbl;+---------------+--------------+| runoob_author | runoob_count |+---------------+--------------+| RUNOOB |20|| 菜鸟教程 | NULL || Google | NULL || FK |20|+---------------+--------------+4 rows inset(0.01 sec)
root@host# mysql -u root -p password;
Enter password:*******
mysql> use RUNOOB;
Database changed
mysql> create table runoob_test_tbl
->(-> runoob_author varchar(40) NOT NULL,-> runoob_count INT
->);
Query OK,0 rows affected (0.05 sec)
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('RUNOOB',20);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('菜鸟教程', NULL);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('Google', NULL);
mysql> INSERT INTO runoob_test_tbl (runoob_author, runoob_count) values ('FK',20);
mysql> SELECT *from runoob_test_tbl;+---------------+--------------+| runoob_author | runoob_count |+---------------+--------------+| RUNOOB |20|| 菜鸟教程 | NULL || Google | NULL || FK |20|+---------------+--------------+4 rows inset(0.01 sec)
mysql> SELECT * FROM runoob_test_tbl WHERE runoob_count = NULL;
Empty set(0.00 sec)
mysql> SELECT * FROM runoob_test_tbl WHERE runoob_count != NULL;
Empty set(0.01 sec)
mysql> SELECT * FROM runoob_test_tbl WHERE runoob_count IS NULL;+---------------+--------------+| runoob_author | runoob_count |+---------------+--------------+| 菜鸟教程 | NULL || Google | NULL |+---------------+--------------+2 rows inset(0.01 sec)
mysql> SELECT *from runoob_test_tbl WHERE runoob_count IS NOT NULL;+---------------+--------------+| runoob_author | runoob_count |+---------------+--------------+| RUNOOB |20|| FK |20|+---------------+--------------+2 rows inset(0.01 sec)
三、MySQL 正则表达式
MySQL 正则表达式
MySQL 正则表达式
mysql> SELECT name FROM person_tbl WHERE name REGEXP '^st';
mysql> SELECT name FROM person_tbl WHERE name REGEXP 'ok$';
mysql> SELECT name FROM person_tbl WHERE name REGEXP 'mar';
mysql> SELECT name FROM person_tbl WHERE name REGEXP '^[aeiou]|ok$';
四、总结
以上就是一些有关Mysql的知识,后续还会继续更新的,谢谢大家的阅读与支持了啦,期待大家的持续的支持了啦。
本文转载自: https://blog.csdn.net/m0_54218263/article/details/122774733
版权归原作者 hhh江月 所有, 如有侵权,请联系我们删除。
版权归原作者 hhh江月 所有, 如有侵权,请联系我们删除。