Cartesian product not correct

Поиск
Список
Период
Сортировка
От Angus Miller
Тема Cartesian product not correct
Дата
Msg-id 4AAE40A1.6050606@spinnaker-ims.com
обсуждение исходный текст
Ответы Re: Cartesian product not correct
Re: Cartesian product not correct
Список 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 по дате отправления:

Предыдущее
От: Nathaniel
Дата:
Сообщение: Bulk read
Следующее
От: Psicopunk
Дата:
Сообщение: Re: Postgresql Hardware