Home  >  Article  >  Database  >  How to check if a field is empty in mysql

How to check if a field is empty in mysql

coldplay.xixi
coldplay.xixiOriginal
2020-10-12 10:57:5710694browse

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)].

How to check if a field is empty in mysql

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<>&#39;&#39;
Select   *   From   table_name Where id!=&#39;&#39;

2, empty

Select   *   From   table_name Where id=&#39;&#39;
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn