From: Josh Berkus <josh@agliodbs.com>
To: Jodi Kanter <jkanter@virginia.edu>
To: Postgres SQL List <pgsql-sql@postgresql.org>
Subject: Re: join syntax
Date: Tue, 17 Jun 2003 11:48:09 -0700
Message-ID: <200306171148.09162.josh@agliodbs.com> (raw)
In-Reply-To: <3EEF6170.1040905@virginia.edu>
References: <3EEF6170.1040905@virginia.edu>
Jodi,
> 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.
table_a JOIN table_b USING (exp_id)
> 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..
That, we can't help you with.
Point out to your friend, though, that an explicit JOIN order can often harm
performance when the JOIN order given by the query writer is not ideal. That
is, the "FROM table, table, table WHERE expression, expression" syntax gives
the parser a freer hand to choose the fastest execution method. Of course,
on a very small database that typically makes litte difference.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: josh@agliodbs.com, jkanter@virginia.edu
Subject: Re: join syntax
In-Reply-To: <200306171148.09162.josh@agliodbs.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