Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id F1FF72E38C6 for ; Fri, 25 Jan 2008 13:21:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 08498-01-2 for ; Fri, 25 Jan 2008 13:20:52 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 2B81F2E38DB for ; Fri, 25 Jan 2008 13:20:53 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m0PHKokV002119; Fri, 25 Jan 2008 12:20:50 -0500 (EST) To: "Scott Marlowe" cc: "acec acec" , pgsql-sql@postgresql.org Subject: Re: This SQL works under Mysql, not Postgresql. In-reply-to: References: <692719.53428.qm@web63009.mail.re1.yahoo.com> Comments: In-reply-to "Scott Marlowe" message dated "Fri, 25 Jan 2008 10:23:53 -0600" Date: Fri, 25 Jan 2008 12:20:50 -0500 Message-ID: <2118.1201281650@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/200 X-Sequence-Number: 30053 "Scott Marlowe" writes: > On Jan 25, 2008 10:11 AM, acec acec 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