开发者

SQL QUERY problem bookid

开发者 https://www.devze.com 2023-01-17 09:45 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消