我无法正确加入以下3个表:
AUTHORS (au_id, au_lname, au_fname, phone, address, city, state, country, postalcode)
TITLES (title_id, title, type, pub_id, price, advance, total_sales, notes, pubdate, contract)
TITLEAUTHOR (au_id, title_id, au_ord, royaltyper)
我的问题是,定价在15到25美元之间的“商业”或“心理学”类型书籍的作者是谁?标题为“作者姓名”(姓和名串联)。
答案 0 :(得分:0)
这应该做...
SELECT CONCAT(a.au_fname, ' ', a.au_lname)
FROM AUTHORS a
JOIN TITLEAUTHOR ta ON a.au_id = ta.au_id
JOIN TITLES t ON ta.title_id = t.title_id
WHERE t.type IN ('business', 'psychology')
AND t.price BETWEEN 15 AND 25
答案 1 :(得分:0)
尝试
SELECT CONCAT(a.au_fname, a.au_lname) as [Author Name]
FROM AUTHORS a
INNER JOIN TITLEAUTHOR ta
ON ta.au_id = a.au_id
INNER JOIN TITLES ti
ON ti.title_id = ta.title_id
WHERE ti.type = 'business' or ti.type = 'psychology'
and ti.price BETWEEN 15 and 25