Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: DaNieL <daniele(dot)pignedoli(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query
Date: 2009-05-04 17:43:04
Message-ID: 20090504194304.3e976c61@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 4 May 2009 09:27:30 -0700 (PDT)
DaNieL <daniele(dot)pignedoli(at)gmail(dot)com> wrote:

[snip]

> Every id in every table is a PRIMARY KEY, UNIQUE, NOT NULL and
> serial type..
> The query that i have problem with is:
> ---
> SELECT
> orders.code,
> customer.name,
> SUM(order_item.price)
> FROM
> orders
> INNER JOIN customer ON (customer.id = orders.id_customer)
> INNER JOIN order_item ON (order_item.id_order = orders.id)
> GROUP BY orders.id

> Sorry, i know that this maybe is a basically problem, but i come
> from mysql.. and in mysql that query works...

You have to add explicitly all the columns not in aggregates.
Postgresql is a bit stricter than mysql but it generally saves you a
lot of debugging later.

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-05-04 18:21:27 Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query
Previous Message Bill Moran 2009-05-04 17:39:28 Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query