Skip site navigation (1) Skip section navigation (2)

Re: Need help with INNER Join

From: Frank Bax <fbax(at)sympatico(dot)ca>
To: PostgreSQL List - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Need help with INNER Join
Date: 2008-05-04 14:52:38
Message-ID: 481DCDB6.10409@sympatico.ca (view raw or flat)
Thread:
Lists: pgsql-novice
Mag Gam wrote:
> When I needed to join tables I always used the equal syntax (ie. SELECT 
> id from foo,fee where id.foo=id.fee)
>  
> To my understanding, it is preferred to use the INNER JOIN keyword. I am 
> able to INNER JOIN 2 tables, but I am not sure of the syntax for 3 or 
> more tables. Can someone please show me an example for that ?


Your example will not work; you should have written:

SELECT foo.id from foo,fee where foo.id=fee.id

With inner join, this would be

SELECT foo.id FROM foo
INNER JOIN fee on foo.id=fee.id

Joining a third table would look like

SELECT foo.id FROM foo
INNER JOIN fee ON foo.id=fee.id
INNER JOIN bar ON bar.id=foo.id



In response to

Responses

pgsql-novice by date

Next:From: Mag GamDate: 2008-05-05 00:12:31
Subject: Re: Need help with INNER Join
Previous:From: Emil ObermayrDate: 2008-05-04 14:52:13
Subject: Re: Need help with INNER Join

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group