Académique Documents
Professionnel Documents
Culture Documents
1701721033137
3RD BCA – B
MCC
CREATING TABLES:
1. Create a table library with the fields : Book, ISBN_NO, Title, Year, Price,
Author_Name, Publisher_Name (set Primary Key)
Command:
Output:
2. Create a table author with the fields: Author_Name and Country
Command:
Output:
Output:
PERFORMING QUERIES:
1. Find the title of the book in library published in the year 2000:
Command:
select title from library where Year = 2000
Output:
2. Find the titles of the book having price between 500 to 600:
Command:
select title from library where Price<600 and Price>500
Output:
3. Find the titles of the book with Author_Name and Country published in the year
2000:
Command:
Output:
4. Display the titles of the book with Author_Name and Author Country:
Command:
Output:
5. Find the names of the Author from Author table where first two character of the
name are “jo”:
Command:
select Author_Name from author where Author_Name like
'Jo%'
Output:
6. Find the Author_Name from author where the second character of the name is
either ‘a’ or ‘e’:
Command:
select Author_Name from author where Author_Name like
'_e%' or Author_Name like '_a%'
Output:
7. Display the names of all publishers where address includes the sub string ‘chen’:
Command:
select Publisher_Name, Publisher_Address from publisher
where Publisher_Address like '%chen%'
Output:
Output:
Output:
10. Find the book with least prices:
Command:
select Title, Price from library where Price = (Select
MIN(Price) from library)
Output:
Output:
Output:
Output:
14. Delete all books from books relation where publishing year is less than 1997:
Command:
Output:
15. Delete all books having price less than average price of books:
Command:
Output:
Output:
17. Increase the price of the book by 15% whose price is less than 200:
Command:
update library set Price = (Price)+(Price * 0.15) where
Price<200
select * from library
Output:
18. Display all titles of book with year in descending order of year:
Command:
select Title, Year from library order by Year desc
Output:
19. Display the title, author and publisher_name of all books published in the year
2000, 2002 and 2004:
Command:
select title, Author_Name, Publisher_Name, Year from
library where Year = 2000 or Year = 2002 or Year = 2004
Output:
20. Get the details of Indian author who have published book in year 2004:
Command:
Output:
21. Display the title, author and publisher of all books except those which are
published in the year 2000, 2002 and 2004:
Command:
select title, Author_Name, Publisher_Name, Year from
library where Year != 2000 and Year != 2002 and Year !=
2004
Output:
22. Get the titles of all books written by authors not living in India:
Command:
select library.Title,library.Author_Name, author.Country
from library, author where author.Country != 'India' and
library.Author_Name = author.Author_Name
Output:
23. Display the titles of books that have price greater than at least one book published
in year 2004:
Command:
Output:
24. Display the titles of books that have price greater than all the books published in
year 2004:
Command:
select Title, Price from library where Price>all(select
Price from library where Year = 2004)
Output:
Output: