Re: join syntax

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Jodi Kanter <jkanter(at)virginia(dot)edu>, Postgres SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: join syntax
Date: 2003-06-17 18:48:09
Message-ID: 200306171148.09162.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-06-17 18:49:44 Re: disabling triggers
Previous Message mallah 2003-06-17 18:47:46 Re: disabling triggers