Skip site navigation (1) Skip section navigation (2)

Re: This SQL works under Mysql, not Postgresql.

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "acec acec" <tomcatacec(at)yahoo(dot)ca>
Cc: "SQL Postgresql List" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: This SQL works under Mysql, not Postgresql.
Date: 2008-01-25 16:32:22
Message-ID: dcc563d10801250832u2f4c4f39l59f625f4e07a5bcb@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Please keep replies on list, others may have answers I do not.

On Jan 25, 2008 10:29 AM, acec acec <tomcatacec(at)yahoo(dot)ca> wrote:
> --- Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
> > On Jan 25, 2008 10:11 AM, acec acec
> > <tomcatacec(at)yahoo(dot)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.

In response to

pgsql-sql by date

Next:From: acec acecDate: 2008-01-25 16:42:21
Subject: Re: This SQL works under Mysql, not Postgresql.
Previous:From: Scott MarloweDate: 2008-01-25 16:29:30
Subject: Re: regex_replace problem -additional

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group