Re: How to get joins to work

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Bill Ewing <wrewing001(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get joins to work
Date: 2006-10-24 22:04:30
Message-ID: 20061024220430.GI30158@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 24, 2006 at 02:43:07PM -0700, Bill Ewing wrote:
> I am having trouble getting joins to work. In a Java app that uses Hibernate 3.1, I am able to build queries that join two, three or more tables using combinations of INNER JOIN, LEFT JOIN or RIGHT JOIN. But, I need FULL OUTER JOIN to work and have not been able to get them to work in Hibernate.
>
> So I decided to go back to basics and practice trial joins in the PgAdminIII Query tool (v1.4.1, Dec 05).
>
> Just to warm up, I did the following simple queries which all worked:
> select * FROM rack r
> select * FROM sample s
>
> The above two tables are linked. But, none of the following SQL worked:
> select * FROM rack r JOIN sample s
> select * FROM rack r INNER JOIN sample s

These statements are incomplete. You need to say what you're joining
on. For example:

select * FROM rack r JOIN sample s USING (joinfield)

or
select * FROM rack r JOIN sample s ON (r.a = s.b);

If you really don't want any constraints, use a comma, or a cross join

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2006-10-24 22:06:43 Re: benchmark suite
Previous Message Magnus Hagander 2006-10-24 21:51:59 Re: 8.2beta1 installation fails