我需要制作以下文件:
Title Publisher Name Author Last Author First
========================================================
Treasure Tauntan Press Smith John
Treasure Tauntan Press Jones Andrew
我的代码如下:
SELECT
Book_Title as 'Title',
Publisher_Name,
Author_Last,
Author_First
FROM BOOK
JOIN PUBLISHER USING (Publisher_Code)
JOIN WROTE USING (Book_Code)
JOIN AUTHOR USING (Author_Num);
select BOOK.*
FROM BOOK
JOIN PUBLISHER USING (Publisher_Code)
JOIN WROTE USING (Book_Code)
JOIN AUTHOR USING (Author_Num)
inner join (
SELECT
Book_Title as Title,
Publisher_Name
FROM BOOK
JOIN PUBLISHER USING (Publisher_Code)
JOIN WROTE USING (Book_Code)
JOIN AUTHOR USING (Author_Num)
group by Book_Title, Publisher_Name
having count(distinct concat(Author_Last,Author_First)) = 2
) t on t.Title = BOOK.Book_Title
and t.Publisher_Name = PUBLISHER.Publisher_Name
它产生如下结果:
Code Book Title Book Type Book Paperback Publisher Code
=================================================================
1234 Treasure Art FALSE AAA
1234 Treasure Art FALSE AAA
需要添加/修改什么才能产生正确的输出?我感谢到目前为止我得到的支持,这是一个陡峭的学习曲线。
1条答案
按热度按时间omjgkv6w1#
可以使用having count(distinct concat(lastname,firstname))=2按标题和发布者分组
以及获取书中与这些书名相关的所有值