Chield Serial
От | lucas@presserv.org |
---|---|
Тема | Chield Serial |
Дата | |
Msg-id | 20050404100102.z7ohducpsei8s0c8@www.presserv.org обсуждение исходный текст |
Список | pgsql-sql |
Hi. Is there a way to make a serial columm that works with father table??? I.e:I have created a table called "vending" and its chield table called "items".The items table have a serial columm, butI need the serial colum starts with 0 for each vending. create table vending ( id serial primary key, --Ok, this serial: 0 - 9999xxx date_ date);create table items ( vending_idreferences vending, items_id serial, -- THIS SERIAL NEED to start 0 for each vending_id primary key (vending_id,items_id));insertinto vending values (1,now());insert into vending values (2,now());insert into items values(1);insert into items values (1);insert into items values (2);insert into items values (2);select * from items; vending_id | items_id 1 | 1 1 | 2 2 | 3 <<=== Here! The items_idneed to be 1 (start again for each vending_id) 2 | 4 <<== Thanks all.
В списке pgsql-sql по дате отправления: