【发布时间】:2021-10-17 01:46:41
【问题描述】:
INSERT INTO inventory (film_id, store_id)
VALUES ((SELECT film_id FROM film WHERE title='EUCLIDEAN PI'), (SELECT store_id from store));
这不起作用。返回的错误是“作为表达式的子查询返回了不止一行”。
基本上,我的库存应该为每家商店都有这部特定电影的副本。如果 ECULIDEAN PI 的 id 是 347。inventory 表应该为 store 表中的每个 store_id 显示 347 的副本。
film_id store_id
347 1
347 2
347 3
347 n
其中 n 是最后一个 store_id。 Store_id 可能并不总是递增的。
【问题讨论】:
-
你用的是什么数据库?
-
我正在使用 postgresql
标签: sql postgresql sql-insert