我有一个图书馆的数据库,里面有学术论文。论文可能有多个合著者,这些信息保存在一个多到多的表格中,因为我也有一个作者表。合著者表类似于:
Paper ID Co-author ID
Paper_1 Author_2
Paper_1 Author_5
Paper_1 Author_7
Paper_3 Author_5
...我需要创建一个查询,返回关于一篇特定论文的所有信息,包括它的合著者。当我尝试这样做的时候,我想到了一张这样的桌子:
Paper ID Paper Name Publication Date Co-author ...
Paper_1 asd 2013 Author_2
Paper_1 asd 2013 Author_5
Paper_1 asd 2013 Author_7我不想重复这件事。我还需要展示论文的引文信息,它也包含在一个多到多的表格中,比如作者,对于这2,当论文有3位共同作者和4篇引文时,该表返回相同的信息12次。我怎么能做到这一点?像这样的桌子会有帮助:
Paper ID Paper Name Publication Date Co-author Cited by
Paper_1 asd 2013 Author_2 Paper_15
Author_5 Paper_22
Author_7 Paper_23
Paper_25或者如果你对桌子的设计有更好的想法,我会接受的。提前谢谢。
发布于 2015-05-31 22:52:35
我建议你保留最初的结果.
Paper ID Paper Name Publication Date Co-author ...
Paper_1 asd 2013 Author_2
Paper_1 asd 2013 Author_5
Paper_1 asd 2013 Author_7如果检查上面的内容,每一行都有一个Paper ID作为标识符。您想要的结果实际上是不完整的数据,实际上您所要求的是对查看器来说不完整的空数据。
Paper ID Paper Name Publication Date Co-author Cited by
Paper_1 asd 2013 Author_2 Paper_15
NULL NULL NULL Author_5 Paper_22
NULL NULL NULL Author_7 Paper_23
NULL NULL NULL NULL Paper_25从您想要的结果来看,对于Paper_25来说,从技术上讲,没有任何与Cited By行相关的数据,因此它是多余的。SQL语言并不完全是为样式目的而构建的,您最好将这种格式设置为电子表格程序或网站样式表。
https://stackoverflow.com/questions/30563127
复制相似问题