Re: How to get joins to work

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
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 23:11:46
Message-ID: 9B71F9ED-2A64-4F95-80BE-556751110AE6@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Oct 25, 2006, at 6:43 , Bill Ewing wrote:

> 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
>
>
> In each case I get a message "ERROR: syntax error at end of input
> at character X" where X is the last character in the statement.
>
> What am I doing wrong?

Unless you're using NATURAL JOIN, you need to specify the join
condition using a USING or ON clause, e.g.,

SELECT *
FROM rack r
JOIN sample s USING (rack_id)

or

SELECT *
FROM rack r
JOIN sample s ON (r.rack_id = s.rack_id)

That should do it.

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2006-10-24 23:23:27 Re: [GENERAL] Call for Donations
Previous Message Peter Eisentraut 2006-10-24 23:02:30 Re: [GENERAL] Call for Donations