Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
051b52c8
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
051b52c8
编写于
12月 11, 2006
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add FAQ entry to mention using COALESCE() for concatenation of possible
NULLs.
上级
9fa12ddd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
11 deletion
+30
-11
doc/FAQ
doc/FAQ
+13
-5
doc/src/FAQ/FAQ.html
doc/src/FAQ/FAQ.html
+17
-6
未找到文件。
doc/FAQ
浏览文件 @
051b52c8
Frequently Asked Questions (FAQ) for PostgreSQL
Last updated:
Tue Dec 5 18:13:32
EST 2006
Last updated:
Mon Dec 11 17:44:33
EST 2006
Current maintainer: Bruce Momjian (bruce@momjian.us)
...
...
@@ -59,8 +59,9 @@
4.8) How do I perform regular expression searches and case-insensitive
regular expression searches? How do I use an index for
case-insensitive searches?
4.9) In a query, how do I detect if a field is NULL? How can I sort on
whether a field is NULL or not?
4.9) In a query, how do I detect if a field is NULL? How do I
concatenate possible NULLs? How can I sort on whether a field is NULL
or not?
4.10) What is the difference between the various character types?
4.11.1) How do I create a serial/auto-incrementing field?
4.11.2) How do I get the value of a SERIAL insert?
...
...
@@ -631,15 +632,22 @@
upper and lowercase characters, it can not have identical values that
differ only in case. To force a particular case to be stored in the
column, use a CHECK constraint or a trigger.
4.9) In a query, how do I detect if a field is NULL? How do I
concatenate possible NULLs? How can I sort on whether a field is NULL
or not?
4.9) In a query, how do I detect if a field is NULL? How
can I sort on
whether a field is NULL or not?
4.9) In a query, how do I detect if a field is NULL? How
do I concatenate
possible NULLs? How can I sort on
whether a field is NULL or not?
You test the column with IS NULL and IS NOT NULL, like this:
SELECT *
FROM tab
WHERE col IS NULL;
To concatentate with possible NULLs, use COALESCE(), like this:
SELECT COALESCE(col1, '') || COALESCE(col2, '')
FROM tab
To sort by the NULL status, use the IS NULL and IS NOT NULL modifiers
in your ORDER BY clause. Things that are true will sort higher than
things that are false, so the following will put NULL entries at the
...
...
doc/src/FAQ/FAQ.html
浏览文件 @
051b52c8
...
...
@@ -10,7 +10,7 @@
alink=
"#0000ff"
>
<H1>
Frequently Asked Questions (FAQ) for PostgreSQL
</H1>
<P>
Last updated:
Tue Dec 5 18:13:32
EST 2006
</P>
<P>
Last updated:
Mon Dec 11 17:44:33
EST 2006
</P>
<P>
Current maintainer: Bruce Momjian (
<A
href=
"mailto:bruce@momjian.us"
>
bruce@momjian.us
</A>
)
...
...
@@ -86,8 +86,8 @@
searches and case-insensitive regular expression searches? How do I
use an index for case-insensitive searches?
<BR>
<A
href=
"#item4.9"
>
4.9
</A>
) In a query, how do I detect if a field
is
<SMALL>
NULL
</SMALL>
? How
can I sort on whether a field is
<SMALL>
NULL
</SMALL>
or not?
<BR>
is
<SMALL>
NULL
</SMALL>
? How
do I concatenate possible
<SMALL>
NULL
</SMALL>
s?
How can I sort on whether a field is
<SMALL>
NULL
</SMALL>
or not?
<BR>
<A
href=
"#item4.10"
>
4.10
</A>
) What is the difference between the
various character types?
<BR>
<A
href=
"#item4.11.1"
>
4.11.1
</A>
) How do I create a
...
...
@@ -823,10 +823,14 @@ table?</TD><TD>unlimited</TD></TR>
identical values that differ only in case. To force a particular
case to be stored in the column, use a
<SMALL>
CHECK
</SMALL>
constraint or a trigger.
</P>
<A
href=
"#item4.9"
>
4.9
</A>
) In a query, how do I detect if a field
is
<SMALL>
NULL
</SMALL>
? How do I concatenate possible
<SMALL>
NULL
</SMALL>
s?
How can I sort on whether a field is
<SMALL>
NULL
</SMALL>
or not?
<BR>
<H3
id=
"item4.9"
>
4.9) In a query, how do I detect if a field
is
<SMALL>
NULL
</SMALL>
? How
can I sort on whether a field is
<SMALL>
NULL
</SMALL>
or not?
</H3>
is
<SMALL>
NULL
</SMALL>
? How
do I concatenate possible
<SMALL>
NULL
</SMALL>
s?
How can I sort on whether a field is
<SMALL>
NULL
</SMALL>
or not?
</H3>
<P>
You test the column with
<SMALL>
IS NULL
</SMALL>
and
<SMALL>
IS
NOT NULL
</SMALL>
, like this:
</P>
...
...
@@ -837,6 +841,13 @@ table?</TD><TD>unlimited</TD></TR>
WHERE col IS NULL;
</PRE>
<P>
To concatentate with possible
<SMALL>
NULL
</SMALL>
s, use
<I>
COALESCE()
</I>
,
like this:
</P>
<PRE>
SELECT COALESCE(col1, '') || COALESCE(col2, '')
FROM tab
</PRE>
<P>
To sort by the
<SMALL>
NULL
</SMALL>
status, use the
<SMALL>
IS NULL
</SMALL>
and
<SMALL>
IS NOT NULL
</SMALL>
modifiers in your
<SMALL>
ORDER BY
</SMALL>
clause.
Things that are
<I>
true
</I>
will sort higher than things that are
<I>
false
</I>
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录