Home > Database > Mysql Tutorial > body text

How to check if a field is empty in mysql

coldplay.xixi
Release: 2020-10-12 10:57:57
Original
10715 people have browsed it

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;
Copy after login

2, empty

Select   *   From   table_name Where id=&#39;&#39;
Select   *   From   table_name Where   ISNULL(id)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template