如何选择字段不为空/空的行 [英] How to select rows where field is not blank/empty

查看:57
本文介绍了如何选择字段不为空/空的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 phpMyAdmin 中执行 MySQL 查询.我想找到一个条目,其中 fieldone 不为 NULL 或不为空/空白,因为我继承了系统,因此字段设置为 NULL,有些只是空白.

I'm trying to do a MySQL query in phpMyAdmin. I want to find an entry where fieldone is not NULL or is not empty/blank as I inherited the system so fields are set to NULL and some are just blank.

无论如何,这是我正在尝试的查询

Anyways, Here is the query I'm trying

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone != ' '
OR fieldone IS NOT NULL

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone <> ' '
OR fieldone IS NOT NULL

都在包含

WHERE fieldone != ' '

WHERE fieldone <> ' '

NOT NULL 部分效果很好,它只是试图找到任何空白字段.

The NOT NULL part works great, its just trying to find any fields that are blank.

推荐答案

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone != ''
OR fieldone IS NOT NULL

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone <> ''
OR fieldone IS NOT NULL

当你的意思是 NULL 值时,不要在你的 '' 之间包含一个空格,所以它意味着没有内容

When you mean NULL value then don't include a space between your '' so it means NO CONTENT

这篇关于如何选择字段不为空/空的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆