Skip to content

Commit 4f34f55

Browse files
committed
Description of table expressions, including join syntax, from Robert B.
Easter <reaster@comptechnews.com>, heavily massaged by me. Also cleaned up value expressions a bit.
1 parent d7d51bc commit 4f34f55

File tree

2 files changed

+844
-219
lines changed

2 files changed

+844
-219
lines changed

doc/src/sgml/func.sgml

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.48 2001/01/20 20:59:28 petere Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.49 2001/01/21 22:02:01 petere Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -24,6 +24,102 @@
2424
other implementations.
2525
</para>
2626

27+
28+
<sect1 id="functions-logical">
29+
<title>Logical Operators</title>
30+
31+
<para>
32+
The usual logical operators are available:
33+
34+
<simplelist>
35+
<member>AND</member>
36+
<member>OR</member>
37+
<member>NOT</member>
38+
</simplelist>
39+
40+
SQL uses a three-valued boolean logic where NULL represents
41+
<quote>unknown</quote>. Observe the following truth tables:
42+
43+
<informaltable>
44+
<tgroup cols="4">
45+
<thead>
46+
<row>
47+
<entry><replaceable>a</replaceable></entry>
48+
<entry><replaceable>b</replaceable></entry>
49+
<entry><replaceable>a</replaceable> AND <replaceable>b</replaceable></entry>
50+
<entry><replaceable>a</replaceable> OR <replaceable>b</replaceable></entry>
51+
</row>
52+
</thead>
53+
54+
<tbody>
55+
<row>
56+
<entry>TRUE</entry>
57+
<entry>TRUE</entry>
58+
<entry>TRUE</entry>
59+
<entry>TRUE</entry>
60+
</row>
61+
62+
<row>
63+
<entry>TRUE</entry>
64+
<entry>FALSE</entry>
65+
<entry>FALSE</entry>
66+
<entry>TRUE</entry>
67+
</row>
68+
69+
<row>
70+
<entry>TRUE</entry>
71+
<entry>NULL</entry>
72+
<entry>NULL</entry>
73+
<entry>TRUE</entry>
74+
</row>
75+
76+
<row>
77+
<entry>FALSE</entry>
78+
<entry>FALSE</entry>
79+
<entry>FALSE</entry>
80+
<entry>FALSE</entry>
81+
</row>
82+
83+
<row>
84+
<entry>FALSE</entry>
85+
<entry>NULL</entry>
86+
<entry>FALSE</entry>
87+
<entry>NULL</entry>
88+
</row>
89+
</tbody>
90+
</tgroup>
91+
</informaltable>
92+
93+
<informaltable>
94+
<tgroup cols="2">
95+
<thead>
96+
<row>
97+
<entry><replaceable>a</replaceable></entry>
98+
<entry>NOT <replaceable>a</replaceable></entry>
99+
</row>
100+
</thead>
101+
102+
<tbody>
103+
<row>
104+
<entry>TRUE</entry>
105+
<entry>FALSE</entry>
106+
</row>
107+
108+
<row>
109+
<entry>FALSE</entry>
110+
<entry>TRUE</entry>
111+
</row>
112+
113+
<row>
114+
<entry>NULL</entry>
115+
<entry>NULL</entry>
116+
</row>
117+
</tbody>
118+
</tgroup>
119+
</informaltable>
120+
</para>
121+
</sect1>
122+
27123
<sect1 id="functions-comparison">
28124
<title>Comparison Operators</title>
29125

@@ -88,6 +184,23 @@
88184
<literal>&lt;</literal> operator to compare a boolean with
89185
<literal>3</literal>).
90186
</para>
187+
188+
<para>
189+
To check whether a value is or is not NULL, use the constructs
190+
<synopsis>
191+
<replaceable>expression</replaceable> IS NULL
192+
<replaceable>expression</replaceable> IS NOT NULL
193+
</synopsis>
194+
Do <emphasis>not</emphasis> use
195+
<literal><replaceable>expression</replaceable> = NULL</literal>
196+
because NULL is not <quote>equal to</quote> NULL. (NULL represents
197+
an unknown value, so it is not known whether two unknown values are
198+
equal.) <productname>Postgres</productname> implicitly converts
199+
<literal>= NULL</literal> clauses to <literal>IS NULL</literal> to
200+
allow some broken client applications (such as
201+
<productname>Microsoft Access</productname>) to work, but this may
202+
be discontinued in a future release.
203+
</para>
91204
</sect1>
92205

93206

0 commit comments

Comments
 (0)