swap relations to be able to execute a left join

From: David Rio Deiros <driodeiros(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: is04607(at)salleurl(dot)edu
Subject: swap relations to be able to execute a left join
Date: 2005-12-09 17:16:15
Message-ID: 20051209171615.GA30790@milhouse.digitaria.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

The other day, a coworker who loves mysql was complaining to me because
he had a hard time to find out why this query didn't work on PostgreSQL:

SELECT
AR.artifact_id,
AT.type_nm,
AR.title,
U.dept,
FROM
Artifact_Revisions AR,
Revisions_to_Types RTT,
Artifact_Types AT
LEFT JOIN
Users U
on (U.user_id = AR.principal_user_id)
WHERE
AR.revision_id = RTT.revision_id
AND RTT.type_id = AT.type_id
AND AR.revision_id = 28403;

Apparently, once he swapped the 1st (AR) and the 3rd (AT) relation in
the FROM, the query worked.

He took the opportunity to tell how much he doesn't like PostgreSQL and
how much he loves mysql. Apparently, he told me (I didn't confirm it)
in mysql you wouldn't need to swap the order of the relations
to execute the query.

I am sure there is a good reason why you have to swap the relations
in PostgreSQL. Anyone?

Thanks,

David

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-12-09 17:16:57 Re: Solaris 10 Sun Studio 11 compile error configtest
Previous Message William 2005-12-09 17:11:32 Solaris 10 Sun Studio 11 compile error configtest