如何在MySQL中跳过空白数据? [英] How to skip blank data in MySQL?

查看:314
本文介绍了如何在MySQL中跳过空白数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跳过MySQL中的空白数据.

I wanted to skip blank data in MySQL.

我的示例查询是:

SELECT id, name, date from sample where name IS NOT NULL;

样品表:

id     name         date
1                  24-04-2012
2      abc         23-04-2012

现在,如果我在上面的查询中触发,它会给我两个记录,但我想跳过存储为空白的数据,即什么都没有(甚至没有NULL )?

Now if I fire above query, it gives me both record but I want to skip data which is stored as blank i.e. There is nothing(not even NULL)?

那么我该如何跳过第一条记录?我应该查询什么?

So how can I skip 1st record? What should be my query?

那么如何在MySQL中跳过空白数据?

请指导我.

推荐答案

您可以使用以下方法从结果中消除NULL和空/空白字符串:

You can eliminate both NULL and empty/blank strings from your results using the following:

 where name IS NOT NULL AND name <> ''
                        ^^^^^^^^^^^^^^ add this

演示: http://www.sqlfiddle.com/#!2/1155a/6

编辑:正如评论中指出的,trim甚至不是必需的.

Edit: As pointed out in the comments, trim is not even necessary.

这篇关于如何在MySQL中跳过空白数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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