Cartesian product not correct - Mailing list pgsql-general

From Angus Miller
Subject Cartesian product not correct
Date
Msg-id 4AAE40A1.6050606@spinnaker-ims.com
Whole thread Raw
Responses Re: Cartesian product not correct  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Cartesian product not correct  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
List 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


pgsql-general by date:

Previous
From: Nathaniel
Date:
Subject: Bulk read
Next
From: Psicopunk
Date:
Subject: Re: Postgresql Hardware