SQL QUERY problem bookid
How do Find开发者_C百科 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
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.
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
精彩评论