is null and = NULL in MySQL

Source: Internet
Author: User

==null and is null are always mistaken, now summarize the mistakes you have encountered in your work.

1, at the time of inquiry

Select * from user where name is null;

< Span class= "Sql1-space" > select  * from user  where name is not null

< Span class= "Sql1-space" > 2, when updated

< Span class= "Sql1-reservedword" > < Span class= "Sql1-space" >update  user set name = Null < Span class= "Sql1-space" >where id = 1

< Span class= "Sql1-space" > < Span class= "Sql1-symbol" >3 , count (1) and limit cannot use

< Span class= "Sql1-reservedword" > < Span class= "Sql1-space" >< Span class= "Sql1-space" >< Span class= "Sql1-space" > select count (1) from user where Name is not null limit 1;

Returns the number of users whose names cannot be empty, It has nothing to do with limit

4 scene: Each user has a note attribute, now find out the note is not" add a meal "user (including not filled in the note), this note by default is empty , There are several options: "Add a Meal" to add spicy" less oil"

select * from user where ifnull(remark, ‘‘ ") != "加一份饭 "

Note: If you write this:Select * from User where remark ! = "plus one meal " Span class= "Sql1-symbol",

so you'll only find records of "spicy" and "low-oil".

is null and = NULL in MySQL

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.