MySQL Delete field is blank data

Source: Internet
Author: User
Tags mysql delete table name

The difference between null and null values

Let's first understand what the difference between a MySQL hollow value and a null is.

Some children who have just come in contact with MySQL often mistakenly assume that Null is the same as the empty string '. This may seem like an unimportant thing, but in MySQL, the two are completely different. Null means no value, and "means that the value exists, but it is a null value."

This is equivalent to the factory to the staff of the House, a total of only a set, Lao Zhang and Old Lee want, but the manager told Lao Zhang, the next time you have your house, but Lao Li has no one to speak to him. So Lao Zhang's house is "empty" because it is a blank cheque, but after all the manager has opened his mouth, and Lao Li's house is null, because no one has considered him.

Some do not understand null value and null what is the difference, misleading beginners.

The so-called null is nothing, not even, in the string is terminator, but in the physical memory is space, equal to a byte, and null is not even this byte. In the database is strictly differentiated, any number and NULL operations are NULL, determine whether the value is equal to NULL, not simple =, and to use the IS keyword, Mysql3.23.0 or later support with <=> to compare two null values are equal, that is, select * From table where ID <=> NULL.

Why does it appear null? This is from the database of the left and right connections, not by fantasy. Like what:

A (ID, Name), B (ID, address)

1, Name1 1, Shanghai

2, Name2 3, Beijing

When a left connection B is obtained:

1, NAME1, Shanghai

2, Name2, NULL

When a right connection B is obtained:

1, NAME1, Shanghai

3, NULL, Beijing

The database's field ID is set to NOT NULL only to indicate that the field cannot be null, which means that only the

INSERT into table (ID) VALUES (NULL);

In this case, the database will complain, and the

INSERT into table (ID) VALUES (');

This does not indicate NULL, the database system is populated with the default values set by the ID, or if the self-added field is automatically added to a

such as default actions.

Cases

Value is null

Delete from table name where field name =null

Value is "" Null value

Delete from table name where field name = '

Summarize

Judge Null with IS NULL or is not NULL. In SQL statements, you can use the Ifnull function to handle

To judge an empty string ', use = ' or ' <> '. The SQL statement can be processed with an if (col,col,0), which means that when Col is true (not NULL, and not "), print 0

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.