请帮助为任务创建视图:
“创建一个视图,其中包含有关每本书的订单总数的信息。视图必须包含两列:“书名”和“订单数”
书名是“名字”,表书-克尼加和订单-扎卡兹
create view info_books as select kniga.name from zakaz, kniga group by kniga.name;
select * from info_books;
但我想我应该
name | count
ee | 2
ew | 1
few | 1
下面是我的例子:https://www.db-fiddle.com/f/gtxitkpglywz5qqpr1lzdx/2
或者在这里:
CREATE TABLE zakaz (
`id_zakaz` INTEGER,
`id_chit` INTEGER,
`data` INTEGER,
`id_knigi` INTEGER
);
CREATE TABLE kniga (
`id_knigi` INTEGER,
`author` CHAR(30),
`name` CHAR(30)
);
INSERT INTO zakaz
(`id_zakaz`, `id_chit`, `data`, `id_knigi`)
VALUES
('1', '1', '123', '33'),
('5', '31', '414', '53'),
('7', '3', '523', '33'),
('4', '4', '52342', '54');
INSERT INTO kniga
(`author`, `name`, `id_knigi`)
VALUES
('abc', 'ee', '33'),
('cfe', 'ew', '53'),
('feaq', 'fewda', '54');
1条答案
按热度按时间8wtpewkr1#
您可以尝试此查询: