Re: This SQL works under Mysql, not Postgresql.

From: "Oliveiros Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>, "acec acec" <tomcatacec(at)yahoo(dot)ca>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: This SQL works under Mysql, not Postgresql.
Date: 2008-01-25 16:52:51
Message-ID: 012101c85f72$b92ca380$ec5a3d0a@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Neither have I.

The LEFT JOIN I know is something like
SELECT ...
FROM table1
LEFT OUTER JOIN table2
ON ....

Try using this construct

Best,
Oliveiros

----- Original Message -----
From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "acec acec" <tomcatacec(at)yahoo(dot)ca>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Friday, January 25, 2008 4:23 PM
Subject: Re: [SQL] This SQL works under Mysql, not Postgresql.

> 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...
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2008-01-25 17:20:50 Re: This SQL works under Mysql, not Postgresql.
Previous Message acec acec 2008-01-25 16:42:21 Re: This SQL works under Mysql, not Postgresql.