Those things about the MySQL database null

  In the mysql database, null is a recurring situation, with regard to the mysql null, what precautions do? Following is a brief summary of the next induction, follow-up will continue to add.

  1. is null

  First, the database determines whether a column value is null, is equal to not be used to determine, to be used is. For example, select * from users where user_name is null or select * from users where user_name is not null, not a select * from users where user_name = null

  2. ISNULL( )

  MySQL database built ISNULL () sum function, using the methods provided in MySQL (), etc. Like the other built-in functions. For example, select ISNULL (user_name) from users where user_name = 'Demrystv' return value is 0; select ISNULL (NULL) return value is 1

  3. IFNULL()

  MySQL database built IFNULL () sum function, using the methods provided in MySQL (), etc. Like the other built-in functions. The main receiving two parameters, the first parameter is determined to be a field or null values, when the second field is a case where the first parameter is a null value to substitute for another return, i.e. if the first field is null, will be replaced with other values. For example, select IFNULL (NULL, "java is the best language of the world"), since the value of the first parameter to NULL, and therefore the output value of the second parameter, java is the best language of the world; Similarly, If the first field is not empty, the value of the first field is returned.

  4. insert into 与null

  When using the table to insert into irrigation data, you need to first clear look at table is null, or empty, if it is null, then it can not be fed using the insert into the data, you must use the update, it may seem simple, but in the actual development is often easy to overlook, and therefore require special attention.

 

Guess you like

Origin www.cnblogs.com/Demrystv/p/11750033.html