mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-30 19:00:29 +08:00
Remove outer join simulation using UNION now that we have had outer
joins for quite a long time.
This commit is contained in:
parent
2de7ebe910
commit
3c16965995
16
doc/FAQ
16
doc/FAQ
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Frequently Asked Questions (FAQ) for PostgreSQL
|
Frequently Asked Questions (FAQ) for PostgreSQL
|
||||||
|
|
||||||
Last updated: Mon Jan 31 21:31:39 EST 2005
|
Last updated: Mon Jan 31 21:35:15 EST 2005
|
||||||
|
|
||||||
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
||||||
|
|
||||||
@ -781,7 +781,7 @@
|
|||||||
4.16) How do I create a column that will default to the current time?
|
4.16) How do I create a column that will default to the current time?
|
||||||
|
|
||||||
Use CURRENT_TIMESTAMP:
|
Use CURRENT_TIMESTAMP:
|
||||||
CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
CREATE TABLE test (x int, modtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
|
||||||
|
|
||||||
4.17) How do I perform an outer join?
|
4.17) How do I perform an outer join?
|
||||||
|
|
||||||
@ -801,18 +801,6 @@
|
|||||||
is assumed in LEFT, RIGHT, and FULL joins. Ordinary joins are called
|
is assumed in LEFT, RIGHT, and FULL joins. Ordinary joins are called
|
||||||
INNER joins.
|
INNER joins.
|
||||||
|
|
||||||
In previous releases, outer joins can be simulated using UNION and NOT
|
|
||||||
IN. For example, when joining tab1 and tab2, the following query does
|
|
||||||
an outer join of the two tables:
|
|
||||||
SELECT tab1.col1, tab2.col2
|
|
||||||
FROM tab1, tab2
|
|
||||||
WHERE tab1.col1 = tab2.col1
|
|
||||||
UNION ALL
|
|
||||||
SELECT tab1.col1, NULL
|
|
||||||
FROM tab1
|
|
||||||
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
|
|
||||||
ORDER BY col1
|
|
||||||
|
|
||||||
4.18) How do I perform queries using multiple databases?
|
4.18) How do I perform queries using multiple databases?
|
||||||
|
|
||||||
There is no way to query a database other than the current one.
|
There is no way to query a database other than the current one.
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
alink="#0000ff">
|
alink="#0000ff">
|
||||||
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
|
<H1>Frequently Asked Questions (FAQ) for PostgreSQL</H1>
|
||||||
|
|
||||||
<P>Last updated: Mon Jan 31 21:31:39 EST 2005</P>
|
<P>Last updated: Mon Jan 31 21:35:15 EST 2005</P>
|
||||||
|
|
||||||
<P>Current maintainer: Bruce Momjian (<A href=
|
<P>Current maintainer: Bruce Momjian (<A href=
|
||||||
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)
|
"mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</A>)
|
||||||
@ -1006,7 +1006,7 @@ length</TD></TR>
|
|||||||
|
|
||||||
<P>Use <I>CURRENT_TIMESTAMP</I>:</P>
|
<P>Use <I>CURRENT_TIMESTAMP</I>:</P>
|
||||||
<PRE>
|
<PRE>
|
||||||
CREATE TABLE test (x int, modtime timestamp DEFAULT CURRENT_TIMESTAMP );
|
CREATE TABLE test (x int, modtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
|
||||||
</PRE>
|
</PRE>
|
||||||
|
|
||||||
<H4><A name="4.17">4.17</A>) How do I perform an outer join?</H4>
|
<H4><A name="4.17">4.17</A>) How do I perform an outer join?</H4>
|
||||||
@ -1032,23 +1032,6 @@ length</TD></TR>
|
|||||||
<SMALL>RIGHT</SMALL>, and <SMALL>FULL</SMALL> joins. Ordinary joins
|
<SMALL>RIGHT</SMALL>, and <SMALL>FULL</SMALL> joins. Ordinary joins
|
||||||
are called <SMALL>INNER</SMALL> joins.</P>
|
are called <SMALL>INNER</SMALL> joins.</P>
|
||||||
|
|
||||||
<P>In previous releases, outer joins can be simulated using
|
|
||||||
<SMALL>UNION</SMALL> and <SMALL>NOT IN</SMALL>. For example, when
|
|
||||||
joining <I>tab1</I> and <I>tab2</I>, the following query does an
|
|
||||||
<I>outer</I> join of the two tables:<BR>
|
|
||||||
<BR>
|
|
||||||
</P>
|
|
||||||
<PRE>
|
|
||||||
SELECT tab1.col1, tab2.col2
|
|
||||||
FROM tab1, tab2
|
|
||||||
WHERE tab1.col1 = tab2.col1
|
|
||||||
UNION ALL
|
|
||||||
SELECT tab1.col1, NULL
|
|
||||||
FROM tab1
|
|
||||||
WHERE tab1.col1 NOT IN (SELECT tab2.col1 FROM tab2)
|
|
||||||
ORDER BY col1
|
|
||||||
</PRE>
|
|
||||||
|
|
||||||
<H4><A name="4.18">4.18</A>) How do I perform queries using
|
<H4><A name="4.18">4.18</A>) How do I perform queries using
|
||||||
multiple databases?</H4>
|
multiple databases?</H4>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user