1010alink ="#0000ff ">
1111< H1 > Frequently Asked Questions (FAQ) for PostgreSQL</ H1 >
1212
13- < P > Last updated:Tue Dec 5 18:13:32 EST 2006</ P >
13+ < P > Last updated:Mon Dec11 17:44:33 EST 2006</ P >
1414
1515< P > Current maintainer: Bruce Momjian (< A href =
1616 "mailto:bruce@momjian.us "> bruce@momjian.us</ A > )
@@ -86,8 +86,8 @@ <H2 align="center">Operational Questions</H2>
8686 searches and case-insensitive regular expression searches? How do I
8787 use an index for case-insensitive searches?< BR >
8888< A href ="#item4.9 "> 4.9</ A > ) In a query, how do I detect if a field
89- is< SMALL > NULL</ SMALL > ? Howcan Isort on whether a field is < SMALL >
90- NULL</ SMALL > or not?< BR >
89+ is< SMALL > NULL</ SMALL > ? Howdo Iconcatenate possible < SMALL > NULL </ SMALL > s?
90+ How can I sort on whether a field is < SMALL > NULL</ SMALL > or not?< BR >
9191< A href ="#item4.10 "> 4.10</ A > ) What is the difference between the
9292 various character types?< BR >
9393< A href ="#item4.11.1 "> 4.11.1</ A > ) How do I create a
@@ -823,10 +823,14 @@ <H3 id="item4.8">4.8) How do I perform regular expression
823823 identical values that differ only in case. To force a particular
824824 case to be stored in the column, use a< SMALL > CHECK</ SMALL >
825825 constraint or a trigger.</ P >
826-
826+
827+ < A href ="#item4.9 "> 4.9</ A > ) In a query, how do I detect if a field
828+ is< SMALL > NULL</ SMALL > ? How do I concatenate possible< SMALL > NULL</ SMALL > s?
829+ How can I sort on whether a field is< SMALL > NULL</ SMALL > or not?< BR >
830+
827831< H3 id ="item4.9 "> 4.9) In a query, how do I detect if a field
828- is< SMALL > NULL</ SMALL > ? Howcan Isort on whether a field is < SMALL >
829- NULL</ SMALL > or not?</ H3 >
832+ is< SMALL > NULL</ SMALL > ? Howdo Iconcatenate possible < SMALL > NULL </ SMALL > s?
833+ How can I sort on whether a field is < SMALL > NULL</ SMALL > or not?</ H3 >
830834
831835< P > You test the column with< SMALL > IS NULL</ SMALL > and< SMALL > IS
832836 NOT NULL</ SMALL > , like this:</ P >
@@ -837,6 +841,13 @@ <H3 id="item4.9">4.9) In a query, how do I detect if a field
837841 WHERE col IS NULL;
838842</ PRE >
839843
844+ < P > To concatentate with possible< SMALL > NULL</ SMALL > s, use< I > COALESCE()</ I > ,
845+ like this:</ P >
846+ < PRE >
847+ SELECT COALESCE(col1, '') || COALESCE(col2, '')
848+ FROM tab
849+ </ PRE >
850+
840851< P > To sort by the< SMALL > NULL</ SMALL > status, use the< SMALL > IS NULL</ SMALL >
841852 and< SMALL > IS NOT NULL</ SMALL > modifiers in your< SMALL > ORDER BY</ SMALL > clause.
842853 Things that are< I > true</ I > will sort higher than things that are< I > false</ I > ,