Practical Programs from Mysql
Practical Programs from Mysql
19) Consider the following tables BOOKS and ISSUE. Write SQL commands for
the statements (i) to (iv) and give outputs for SQL queries (v) to (vi)
Table : Books
Table : Issues
BOOK _ID QTY_ISSUED
LO2 13
LO4 5
LO5 21
i) To show Book name, Author name and price of books of ABC publisher
SELECT BOOKNAME,AUTHORNAME,PRICE FROM BOOKS
WHERE PUBLISHER=’ABC’;
ii)To display the details of the books in descending order of their price.
SELECT * FROM BOOKS ORDER BY PRICE DESC;
iii) To decrease the qty_issued from ISSUES table by 3 (all rows must
decrease)
UPDATE ISSUES SET QTY_ISSUED=QTY_ISSUED-3;
2) Consider the following tables BOOKS and ISSUE. Write SQL commands for
the statements (i) to (iv) and give outputs for SQL queries (v) to (vi)
Table : FACULTY
Table : COURSES
ii) To display the details of courses whose fees is in the range of 15000 to
50000 (both values included).
SELECT * FROM COURSES
WHERE FEES BETWEEN 15000 AND 50000;
iii) To increase the fees of all courses by 500 of “System Design” Course.
UPDATE COURSES SET FEES=FEES+500
WHERE CNAME=’System Design’;
iv) To display details of those courses which are taught by ‘Sulekha’ in
descending order of courses.
SELECT * FROM FACULTY F,COURSES C
WHERE F.F_ID=C.F_ID ORDER BY CNAME DESC;
102
103
104
105
106