【发布时间】:2020-05-23 17:40:08
【问题描述】:
我不明白如何使用RETURNING,例如如何获得“在我手中”的实际价值以进行下一步。假设,我有两张桌子:
create table "actors" (
id_act serial not null primary key,
first_name text not null,
last_name text not null
);
create table movies (
id_mov serial not null primary key,
act_id integer not null
);
现在我添加一个演员:
INSERT INTO actors (first_name, last_name) VALUES ('Tom', 'Hanks');
紧接着,我想用那个新演员的 ID 插入一部电影:
INSERT INTO movies(###);
如何使用RETURNING 代替占位符###?
【问题讨论】:
标签: sql postgresql sql-returning