Re: How to get joins to work - Mailing list pgsql-general

From Michael Glaesemann
Subject Re: How to get joins to work
Date
Msg-id 9B71F9ED-2A64-4F95-80BE-556751110AE6@seespotcode.net
Whole thread Raw
In response to How to get joins to work  (Bill Ewing <wrewing001@yahoo.com>)
Responses Re: How to get joins to work
List 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



pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: [pgsql-advocacy] Call for Donations
Next
From: "Harald Armin Massa"
Date:
Subject: Re: 8.2beta1 installation fails