I have 2 queries I have to create but they sound the same.
Note: I am just learning the theory behind SQL and not actually working on a DB at this time

Directions:
1. Show all the categories for each book with the book number, title, category number, and category name.

2. Show all the books for each category with the categbory number, category name, book number, and book title.

Tables:
Book
(book_id, book_title, publication_date, publisher_id, précis)

Category
(category_id, category_name)

Book_Category
(book_id, category_id)
FK book_id > book
FK category_id > category

This is what I got for #1:

SELECT c.category_id, c.category_name, b.book_id, b.book_title
FROM category c, book b, book_category bc
WHERE bc.book_id = b.book_id
AND bc.category_id = c.category_id
ORDER BY c.category_name, b.book_title;

After looking at #2 I am confused and I have no idea if I did this correctly.
Any help would greatly be appreciated. Thanks a bunch!

Wat exactly do u want?do u want to see the result for the below statement or need to create View for the same and use select to view it?
1. Show all the categories for each book with the book number, title, category number, and category name.
2. Show all the books for each category with the categbory number, category name, book number, and book title.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.