Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views2 pages

Queries 1

Uploaded by

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

Queries 1

Uploaded by

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

Database :Library

Tables:

1. Books
oColumns:
 id (INT, Primary Key, Auto Increment)
 title (VARCHAR(255), Not Null)
 author (VARCHAR(255), Not Null)
 genre (VARCHAR(50))
 publish_year (YEAR)
2. Members
o Columns:
 member_id (INT, Primary Key, Auto Increment)
 name (VARCHAR(255), Not Null)
 contact_info (VARCHAR(255))

Practice Questions:

SELECT:

1. Write a query to retrieve all book titles and authors from the Books table.
2. Write a query to select only the genre and publish_year columns for books
published before 2000.
3. Write a query to retrieve information (all columns) about members whose names start
with the letter "A". (Use the LIKE operator)

WHERE:

4. Find all books written by a specific author (e.g., "J.R.R. Tolkien").


5. Find all books in a specific genre (e.g., "Science Fiction").
6. Find all members who haven't provided their contact information (use NULL check).

AND & OR:

7. Combine conditions: Find all books published after 2010 AND in the "Fantasy"
genre.
8. Combine conditions: Find books written by "Stephen King" OR belonging to the
"Mystery" genre.

NOT:

9. Find all books that are not biographies (assuming genre exists).
10. Find all members who have registered after a specific date (use NOT BETWEEN).

ORDER BY:

11. Order all books alphabetically by title (ascending order).


12. Order all members by name in descending order.
INSERT INTO:

13. Create a new record in the Books table with sample data (specify title, author, genre,
and publish year). (Use INSERT INTO)

NULL VALUES:

14. Insert a new member record with a name but leave the contact_info field blank (use
NULL).

You might also like