Home > Database > Mysql Tutorial > body text

How to determine whether a field is empty in mysql

anonymity
Release: 2020-09-17 09:21:51
Original
43684 people have browsed it

Mysql method to determine whether a field is empty: You can use the isnull() function to determine. The specific code is [select * from users where email = 'xxxx' and isnull(deletedAt)].

How to determine whether a field is empty in mysql

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently a product of Oracle. MySQL is one of the most popular relational database management systems. In terms of WEB applications, MySQL is the best RDBMS (Relational Database Management System) application software.

(Recommended tutorial: mysql video tutorial)

When we need to know whether a certain field in mysql is empty? How to achieve it?

Here are 5 methods for querying:

isnull()

select * from users where email = 'xxxx' and isnull(deletedAt)
Copy after login

is null

select * from users where email = 'xxxx' and deletedAt is null
Copy after login

is not null

select * from users where email = 'xxxx' and deletedAt is not null
Copy after login

!isnull()

select * from users where email = 'xxxx' and !isnull(deletedAt) 
select * from users where email = 'xxxx' and not isnull(deletedAt)
Copy after login

isfull

When the query condition is null, replace it with the specified character

select name,  isfull(gender,'未知') as gender  from users where email = 'xxxx'
Copy after login

The above is the detailed content of How to determine whether 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