相当于ISNULL(),NVL(),IFNULL()或COALESCE SQLite的() [英] SQLite equivalent to ISNULL(), NVL(), IFNULL() or COALESCE()

查看:1834
本文介绍了相当于ISNULL(),NVL(),IFNULL()或COALESCE SQLite的()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以避免许多检查就像在我code以下内容:

I'd like to avoid having many checks like the following in my code:

myObj.someStringField = rdr.IsDBNull(someOrdinal) 
                            ? string.Empty 
                            : rdr.GetString(someOrdinal);

我想我可以有我的查询,照顾空的做这样的事情:

I figured I could just have my query take care of the nulls by doing something like this:

SELECT myField1, [isnull](myField1, '') 
FROM myTable1
WHERE myField1 = someCondition

我使用SQLite的,虽然,它似乎并没有认识到 ISNULL 功能。我也试过在其他数据库(公认的一些等同的 NVL() IFNULL() COALESCE()),但SQLite的似乎不认识任何人。

I'm using SQLite though and it doesn't seem to recognize the isnull function. I've also tried some equivalent ones recognized in other databases (NVL(), IFNULL() and COALESCE()), but SQLite doesn't seem to recognize any of them.

没有人有任何建议或知道的更好的方法来做到这一点。不幸的是数据库没有所有字段的默认值。另外,我需要使用一些 LEFT JOIN在某些情况下,一些返回的字段将是空的,因为在左边的匹配记录JOIN 条款表将不存在。

Does anyone have any suggestions or know of a better way to do this. Unfortunately the database doesn't have default values for all fields. Plus, I need to use some LEFT JOIN clauses in some cases, where some of the fields returned will be null because the matching record in the LEFT JOIN table will not exist.

推荐答案

IFNULL ,在这里看到:<一href="http://www.sqlite.org/lang_corefunc.html#ifnull">http://www.sqlite.org/lang_corefunc.html#ifnull

没有括号功能

这篇关于相当于ISNULL(),NVL(),IFNULL()或COALESCE SQLite的()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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