我创建了一个订单栏,我想更新该表中的当前值。
CREATE TABLE public.publishroomcontacts
(
id integer NOT NULL DEFAULT nextval('publishroomcontacts_id_seq'::regclass),
publishroomid integer NOT NULL,
contactorder integer NOT NULL,
CONSTRAINT publishroomcontacts_pkey PRIMARY KEY (id),
CONSTRAINT fk_publishroomcontacts_publishroom_id FOREIGN KEY (publishroomid)
REFERENCES public.publishrooms (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
)
WITH (
OIDS = FALSE
);
我想做的是遍历所有行,按publishroomid分组并添加一个contactorder。 因此,如果有4个联系人具有相同的publishroomid乳清,则其联系人顺序为1、2、3和4。
我该怎么做?
编辑: