From: Scott Marlowe <scott.marlowe@gmail.com>
To: acec acec <tomcatacec@yahoo.ca>
Cc: SQL Postgresql List <pgsql-sql@postgresql.org>
Subject: Re: This SQL works under Mysql, not Postgresql.
Date: Fri, 25 Jan 2008 10:32:22 -0600
Message-ID: <dcc563d10801250832u2f4c4f39l59f625f4e07a5bcb@mail.gmail.com> (raw)
In-Reply-To: <739387.39197.qm@web63012.mail.re1.yahoo.com>
References: <dcc563d10801250823p3694ee4flc5029b93594ecf66@mail.gmail.com>
<739387.39197.qm@web63012.mail.re1.yahoo.com>
Please keep replies on list, others may have answers I do not.
On Jan 25, 2008 10:29 AM, acec acec <tomcatacec@yahoo.ca> wrote:
> --- Scott Marlowe <scott.marlowe@gmail.com> wrote:
> > 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';
> > > When I ran it under postgresql, which gave me
> > "ERROR:
> > > syntax error at or near"
> > > It looks like I could not put two table on LEFT
> > JOIN:
> > > LEFT JOIN (SERVICE suv, SERVICE sus)
> > >
> > > Do you have any suggestion for this problem?
> >
> > Is that legal SQL? I've never seen anything like
> > that before...
> >
> Maybe it is not legal sql according to SQL standard,
> but it works under mysql, I try to port it into
> Postgresql.
Well, I'd say just breaking each part of the "LEFT JOIN (SERVICE suv,
SERVICE sus)" and the on () clause should work.
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: scott.marlowe@gmail.com, tomcatacec@yahoo.ca
Subject: Re: This SQL works under Mysql, not Postgresql.
In-Reply-To: <dcc563d10801250832u2f4c4f39l59f625f4e07a5bcb@mail.gmail.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