You are on page 1of 3

Update Query:

update characters
set Age = 20
where Character_ID = 17;

update characters
set Age = 49
where Character_ID = 18;

update characters
set Age = 49
where Character_ID = 28;

update characters
set Age = 21
where Character_ID = 30;

Create table:

create table Book_Publisher_Relationship (


Book_No int,
Publisher_ID int,
Price int,
No_Of_Pages int,
primary key (Book_No, Publisher_ID),
foreign key(Book_No) references book(Book_No),
foreign key(Publisher_ID) references publisher(Publisher_ID)
);

insert into Book_Publisher_Relationship(Book_No, Publisher_ID, Price, No_of_Pages) values


(1,1,182,134),
(1,2,90,78),
(2,3,150,156),
(2,4,200,193),
(3,3,300,720),
(3,2,245,704),
(3,4,413,668),
(4,3,165,156),
(4,5,176,184),
(5,6,360,264),
(5,7,238,192),
(5,4,132,95),
(6,8,90,64),
(7,8,140,110),
(8,8,114,80),
(9,9,855,645),
(10,9,1133,768),
(11,9,180,73),
(11,10,123,79),
(12,9,180,90),
(12,10,90,80),
(13,11,233,120),
(14,12,270,217),
(15,13,450,186),
(16,14,298,312),
(16,15,255,300),
(17,16,225,208),
(18,16,375,301),
(19,17,390,null),
(6,15, 123,90),
(7, 15, 150, 112),
(8, 14, 165, 100),
(13, 13, 255, 150),
(17, 12, 270, 205),
(1, 3, 165, 105);

Problem 2.1:

select Book_Name, Genre


from book
where Language = 'Bangla';

Problem 2.2:

SELECT
bcr.Book_No,
MIN(c.Age) AS Min_Age
FROM
book_character_relationship bcr
JOIN
characters c
ON bcr.Character_ID = c.Character_ID
GROUP BY
bcr.Book_No;

Problem 2.3:

select book.Book_Name, characters.Character_Name, characters.Age


from book
join book_character_relationship on book.Book_No = book_character_relationship.Book_No
join characters on book_character_relationship.Character_ID = characters.Character_ID
where (book.Book_No,characters.Age) in (select Book_No, min(Age)
from book_character_relationship
join characters on book_character_relationship.Character_ID = characters.Character_ID
group by Book_No);

You might also like