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

From: Jesse <google(at)jessehersch(dot)fastmail(dot)fm>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query
Date: 2009-05-05 04:29:07
Message-ID: ddc7f358-e433-475e-b147-c019c2d0a4b3@o14g2000vbo.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On May 4, 9:27 am, DaNieL <daniele(dot)pigned(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> Sorry, i know that this maybe is a basically problem, but i come from
> mysql.. and in mysql that query works...

if there's only one name per order, just put a min or max around the
second col. as you know by now, all columns that are not GROUPed BY
must be in an aggregate function.

SELECT
orders.code,
MIN(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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message DaNieL..! 2009-05-05 07:10:56 Re: PGSQL-to-MYSQL Migration: Error in a 'simple' inner join query
Previous Message Alvaro Herrera 2009-05-05 03:17:24 Re: Tracking down a deadlock