Search Postgresql Archives

Re: How to get joins to work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux