Cartesian product not correct

From: Angus Miller <angus(at)spinnaker-ims(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Cartesian product not correct
Date: 2009-09-14 13:09:53
Message-ID: 4AAE40A1.6050606@spinnaker-ims.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

Given the sql below shouldn't I get the 3 records back?

create table t1 (attribute text);
insert into t1 values ('cars');
insert into t1 values ('trucks');
insert into t1 values ('bikes');

create table t2 (id serial, category text, attribute text, val integer);
insert into t2(category, attribute, val) values ('vehicle','cars', 100);

select t2.category, t1.attribute, 0 as val
from t2, t1
where t2.id in (
select max(id)
from t2
group by category
);

PostgreSQL 8.4.0 on windows

Cheers
Angus

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Psicopunk 2009-09-14 13:13:04 Re: Postgresql Hardware
Previous Message Nathaniel 2009-09-14 11:55:43 Bulk read