Re: How to join from two tables at once?

From: Joseph Shraibman <jks(at)selectacast(dot)net>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to join from two tables at once?
Date: 2003-08-28 23:52:25
Message-ID: 3F4E95B9.30204@selectacast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Stephan Szabo wrote:

>
> Probably you want something like:
> SELECT u.uid, u.txt, p.val FROM
> u INNER JOIN a ON (a.id=u.aid)
> LEFT JOIN p ON (p.uid=u.uid AND p.pkey=a.pkey);

From the docs:

A CROSS JOIN or INNER JOIN is a simple Cartesian product, the same as you get from
listing the two items at the top level of FROM. CROSS JOIN is equivalent to INNER JOIN ON
(TRUE), that is, no rows are removed by qualification. These join types are just a
notational convenience, since they do nothing you couldn't do with plain FROM and WHERE.

... so obviously there *is* something that INNER JOIN can do that regular ANDs can't. But
I'm still not clear why one works and the other doesn't.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kumar 2003-08-29 05:24:03 Migrating Stored Procedures from MS SQL Server
Previous Message Michael A Nachbaur 2003-08-28 22:47:51 Forcing a trigger to run