SQL Queries:
Single Table Queries ->
1).Using Table - Students
SELECT * FROM Students;
SELECT Name, Marks FROM Students;
SELECT * FROM Students WHERE Marks > 80;
SELECT COUNT(*) AS TotalStudents FROM
Students;
SELECT * FROM Students WHERE City = 'Delhi';
SELECT Name,Marks FROM Students ORDER BY
Marks DESC
2).Using Table – Books
select * from books;
INSERT INTO books (title, author, genre, quantity)
VALUES ('The Great Gatsby', 'F. Scott Fitzgerald', 'Fiction', 5);
UPDATE books SET quantity = 20 WHERE book_id = 1;
SELECT * FROM books
WHERE genre = 'Science Fiction';
DELETE FROM books
WHERE book_id = 8;
select * from books
where quantity> 10;
3).Using Table – Transactions
SELECT * FROM transactions;
DELETE FROM transactions WHERE transaction_id = 4;
SELECT * FROM transactions WHERE member_id = 3;
UPDATE transactions SET return_date = '2024-12-20' WHERE
transaction_id = 2;
INSERT INTO transactions (book_id, member_id, issue_date,
return_date) VALUES (1, 3, '2024-12-01', '2024-12-15');
4).Using Table – Members
SELECT * FROM members;
INSERT INTO members (name, email, phone) VALUES ('John
Doe', '
[email protected]', '9876543210');
UPDATE members SET phone = '9123456789' WHERE
member_id = 3;
DELETE FROM members WHERE member_id = 7;
SELECT * FROM members WHERE name LIKE '%Bob
Smith';
5).Using Table – Courses:
select * from Courses;
INSERT INTO Courses (CourseID,CourseName, Duration)
values ( 104,"CS" , "5 Months");
Update courses set Duration = '12 Month' where
courseID = 101;
Delete from courses where coursed = 104 ;
select * from Courses order by CourseID desc;
PYTHON-SQL Connectivity:
1. Creating Multiple Databases :
2.Adding data in these Databases:
3. Python Program to Retrieve All Students with Their
Enrolled Courses
4. Python Program to Find the Total Number of
Students Enrolled in Each Course
5. Python Program to Retrieve Students with Marks
Greater Than a Given Value