-1

我无法正确加入以下 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 美元之间的“商业”或“心理学”类书籍的作者是谁?将标题设为“作者姓名”(连接名字和姓氏)。

4

2 回答 2

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 
于 2018-10-11T15:30:39.050 回答
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
于 2018-10-11T15:37:40.830 回答