Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How mysql deletes empty data

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of mysql how to delete empty data, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this mysql article on how to delete empty data. Let's take a look.

In mysql, you can use the delete statement with "NULL" to delete empty data, which is used to delete the data record in the table, "NULL" is used to indicate that the data is empty, and the syntax is "delete from table name where field name =''OR field name IS NULL;".

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How does mysql delete empty data

Use the delete command to delete blank lines in MySQL.

The syntax is as follows

Delete from yourTableName where yourColumnName=''OR yourColumnName IS NULL

The above syntax removes blank lines and NULL lines.

To understand this concept, let's create a table. The query to create the table is as follows

Mysql > create table deleteRowDemo-> (- > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,-> StudentName varchar (20)->)

Insert some records in the table using the insert command.

The query is as follows

Mysql > insert into deleteRowDemo (StudentName) values ('John'); mysql > insert into deleteRowDemo (StudentName) values (''); mysql > insert into deleteRowDemo (StudentName) values (''); mysql > insert into deleteRowDemo (StudentName) values (NULL); mysql > insert into deleteRowDemo (StudentName) values ('Carol'); mysql > insert into deleteRowDemo (StudentName) values (' Bob'); mysql > insert into deleteRowDemo (StudentName) values (''); mysql > insert into deleteRowDemo (StudentName) values ('values)

Use the select statement to display all records in the table.

The query is as follows

Mysql > select * from deleteRowDemo

Here is the output

+-+-- +-+ | Id | StudentName | +-+-+ | 1 | John | 2 | | 3 | | 4 | NULL | | 5 | Carol | | 6 | Bob | | 7 | | 8 | David | + -+ 8 rows in set (0.00 sec)

This is a query that deletes blank lines and NULL

Mysql > delete from deleteRowDemo where StudentName='' OR StudentName IS NULL

Now, let's check the table record again.

The query is as follows

Mysql > select * from deleteRowDemo

Here is the output

+-this is the end of the article on "how to delete empty data by mysql". This is the end of the article on "how to delete empty data by mysql". This is the end of the article. Thank you for reading! I believe you all have a certain understanding of "how to delete empty data in mysql". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report