pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Scott Marlowe <scott.marlowe@gmail.com>
Cc: acec acec <tomcatacec@yahoo.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: This SQL works under Mysql, not Postgresql.
Date: Fri, 25 Jan 2008 12:20:50 -0500
Message-ID: <2118.1201281650@sss.pgh.pa.us> (raw)
In-Reply-To: <dcc563d10801250823p3694ee4flc5029b93594ecf66@mail.gmail.com>
References: <692719.53428.qm@web63009.mail.re1.yahoo.com>
	<dcc563d10801250823p3694ee4flc5029b93594ecf66@mail.gmail.com>

"Scott Marlowe" <scott.marlowe@gmail.com> writes:
> On Jan 25, 2008 10:11 AM, acec acec <tomcatacec@yahoo.ca> wrote:
>> I have the following sql, which works fine under mysql
>> database:
>> SELECT sa.ID, suv.TOTAL as VOICE_TOTAL, sus.TOTAL as
>> SMS_TOTAL FROM SUB_ACCOUNT sa INNER JOIN SUBSCRIBER s
>> ON (sa.ID = s.SUB_ACCOUNT_ID) LEFT JOIN (SERVICE suv,
>> SERVICE sus) ON (sa.ID = suv.SUB_ACC_ID AND
>> suv.SERVICE_ID = 0 AND sa.ID = sus.SUB_ACC_ID AND
>> sus.SERVICE_ID = 1) WHERE s.TELEPHONE = '111111111';

> Is that legal SQL?

It is not, though given mysql's historical inability to implement the
JOIN syntax per-spec, it's not too surprising that they'd show such a
weak grasp of correct syntax.  Maybe replace the comma with CROSS JOIN?

... (SERVICE suv CROSS JOIN SERVICE sus) ...

			regards, tom lane



view thread (6+ messages)

Message-ID: <2118.1201281650@sss.pgh.pa.us>
Permalink:  ../2118.1201281650@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2118.1201281650@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, scott.marlowe@gmail.com, tomcatacec@yahoo.ca
  Subject: Re: This SQL works under Mysql, not Postgresql.
  In-Reply-To: <2118.1201281650@sss.pgh.pa.us>

* 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