Mysql method to check whether the field is empty: 1. The query is not empty, the code is [Select * From table_name Where id!='']; 2. The query is empty, the code is [Select * From table_name WhereISNULL(i)].
Mysql method to check whether a field is empty:
Different databases in the sql standard have different function usage In use today, I found that the query ranking function in mysql does not support top in MySQL. This top function is a function of sql server.
Let’s briefly talk about the methods of querying null and non-null in MySQL. The space is divided into the empty ' '; and null of the string
1, not empty
Select * From table_name Where id<>'' Select * From table_name Where id!=''
2, empty
Select * From table_name Where id='' Select * From table_name Where ISNULL(id)
Specific analysis of the specific situation, if the field is char If it is a varchar type, use id=''; if it is an int type, it is better to use ISNULL.
More related free learning recommendations:mysql tutorial(video)
The above is the detailed content of How to check if a field is empty in mysql. For more information, please follow other related articles on the PHP Chinese website!