pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Postgres SQL List <pgsql-sql@postgresql.org>
Subject: Re: join syntax
Date: Tue, 17 Jun 2003 12:53:48 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com> (raw)
In-Reply-To: <3EEF6170.1040905@virginia.edu>

On Tue, 17 Jun 2003, Jodi Kanter wrote:

> One of my colleagues has created a database where he has the same field 
> name in two tables and uses this field to link his tables rather than 
> some arbitrary value. For example, he has used "exp_id" in two tables. 
> When writing his joins he uses a syntax that says something like JOIN ON 
> EXP_ID. Can someone tell me what that syntax should be? I am not very 
> familiar with it since I typically use the syntax where one field is set 
> equal to the other.
> Personally I prefer not to set databases up this way but cannot seem to 
> convince him of this. And yet I am supposed to now help him with his 
> database and application.. Is there some documentation that would define 
> this type of syntax? How is this handled if you have more than one table 
> in the join? It does not appear that this format would allow for this.

If you're joining two tables on a field that has the same name you can use 
a natural join.

select * from table1 natural join table2;




view thread (5+ messages)

Message-ID: <Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: scott.marlowe@ihs.com, jkanter@virginia.edu
  Subject: Re: join syntax
  In-Reply-To: <Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com>
  References: <3EEF6170.1040905@virginia.edu> <Pine.LNX.4.33.0306171253220.2647-100000@css120.ihs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox