1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Backpatch FAQ entry for null concatenation.

This commit is contained in:
Bruce Momjian
2006-12-11 22:48:08 +00:00
parent 3647ff3b3a
commit d94fa4183f
9 changed files with 80 additions and 42 deletions

18
doc/FAQ
View File

@ -1,7 +1,7 @@
Frequently Asked Questions (FAQ) for PostgreSQL
Last updated: Sat Dec 2 07:15:34 EST 2006
Last updated: Mon Dec 11 17:45:54 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