0% found this document useful (0 votes)
43 views

Write a program to connect Python with MySQL using database connectivity and perform the following operations on data in database_094126

Sql program

Uploaded by

skvjict
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Write a program to connect Python with MySQL using database connectivity and perform the following operations on data in database_094126

Sql program

Uploaded by

skvjict
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Write a program to connect Python with MySQL using

database connectivity and perform the following operations on


data in database: Create a table, Insert the data, Fetch the
data, update the data, and delete the data.

TABLE
PROGRAM

OUTPUT
Updating the data Deleting the data.

5. Consider the following tables and answer the following Table :


Table
:
Libra
ry
Book_Id Book_Name Author_Nam Publishe Price Type Quantity
e r
C0001 Fast Cook LataKapoor EPB 355 Cooker 5
y
F0001 The Tears William First Pub 650 Fiction 20
Hopkins
T0001 My First C++ Brain & EPB 350 Text 10
Brooke
T0002 C++ Brain A.W. Rossaine TDH 350 Text 15
works
F0002 Thunderbolts Anna Roberts First Pub 750 Fiction 50
Tabl
e:
Issue
d
Book_Id Issuedto Quantity_Issue
d
T0001 Kamal 4
C0001 Arvind 5
F0001 Suresh 2
1. To show Book id, Book name, Author name and price of books of First
Pub Publisher

2. To display the names and price of books in ascending order of their


prices.

3. Display the price of book which has price between 300 to 500.

4. To increase the price of all books of EPB publishers by 50.

5. To display the Book_Id, Book_Name and quantity issued for all books
which have been issued.
6. To display the Bookname and Price of Books for all books having „C++‟
in the bookname

7. Delete the book whose book id is T0002

8. Show all book whose book name started with character „T‟

9. Select Count(*) from Book;

10. Select Max(Price) from Book where Quantity >=15;


11. Select Book_Name, Author_Name from Book where
Publisher=‟First Publ.‟;

12. Select count(distinct Publisher) from Book where Price>=400;

13. Select count(distinct(Publisher)) from book;

6. Consider the following table hospital and answer


the questions.

NO NAME AGE DEPARTMENT DATEOFADM CHARGES SEX


1 Arpit 62 Surgery 21/1/98 300 M
2 Zareen 22 Ent 12/12/97 250 F
a
3 Kareem 32 Arthopedic 19/2/98 200 M
4 Arun 12 Surgery 11/1/98 300 M
5 Zubin 30 Ent 12/1/98 250 M
6 Karin 16 Ent 24/2/98 250 F
7 Ankita 29 cardiology 22/2/98 800 F
8 Zareen 45 Gynecology 22/2/98 300 F
9 Kush 19 Cardiology 13/1/98 800 M
10 Shilpa 23 Nuclear 21/2/98 NULL F
medicine
1. Write a SQL command to create the table hospital.

2. Write a SQL command to insert the values in the table .

3. To select all the information of patients of all cardiology department.

4. To list the names of female patients who are in ent department.


5. To list names of all patients with their date of admission in ascending
order.

6. To display patients name, charges, age, for only female patients

7. To count the number of patients with age <30.

8. Write a SQL command to remove the records of all female doctors

9. Write a SQL command to show the details name ,age and


department whose name start
with „A‟

10. Write a SQL command to delete the column charges from hospital
table.
11. Write a SQL command to increase the charges by 10% for all ENT
doctors

12. Write a SQL command to display the different departments.

13. Write a SQL command to show the maximum charges of male and
female doctors.

14. Write a SQL command to display the details of all male doctors whose
age is between 19-
35.

15. Write a SQL command to count number of doctors working in each


department.
16. Select count(*) from hospitals where age<30;

17. Select count (distinct charges)from hospital;

18.Select min(age) from hospital where sex = „F‟;

19.Select sum(charges) from hospital where department = „ENT‟;

20.Select max(charges) from hospital where sex=‟F‟;

You might also like