Search Postgresql Archives

Re: How to get joins to work

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

 



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@xxxxxxxxx>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment: signature.asc
Description: Digital signature


[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