Sasha Becon
Sasha Becon

Reputation: 1

SQL QUERY problem bookid

How do Find books (show their titles, authors and prices) that are on 'CIVIL WAR' (i.e., the title field contains 'CIVIL WAR'), available in 'AUDIO' format.

this is my schema * Books (bookid, title, author, year) * Customers (customerid, name, email) * Purchases (customerid, bookid, year) * Reviews (customerid, bookid, rating) * Pricing (bookid, format, price)

I did this but it did not work SELECT b.title, b.author, p.price FROM BOOKS b,PRICING p INNER JOIN books ON p.bookid WHERE b.title like '%CIVIL WAR%' AND p.format like '%AUDIO%' group by p.format, p.price

Upvotes: 0

Views: 940

Answers (2)

JoshD
JoshD

Reputation: 12814

It looks like the ON clause is incomplete.

Try this:


SELECT b.title, b.author, p.price
FROM BOOKS b
INNER JOIN PRICING p ON p.bookid = b.bookid 
WHERE b.title like '%CIVIL WAR%' 
AND p.format like '%AUDIO%' group by p.format, p.price

See the = b.bookid at the end of the INNER JOIN? That's the issue.

Upvotes: 2

Andy Groff
Andy Groff

Reputation: 2670

Maybe:

 SELECT b.title, b.author, p.price 
 FROM BOOKS b
 INNER JOIN PRICING p ON p.bookid=b.bookid 
 WHERE b.title like '%CIVIL WAR%' AND p.format like '%AUDIO%' group by p.format, p.price

Upvotes: 1

Related Questions