sql - Creating a query that uses many to many tables -
i have database of library contains academic papers. papers may have multiple co-authors , information kept in many-to-many table since have table of authors. co-author table like:
paper id co-author id paper_1 author_2 paper_1 author_5 paper_1 author_7 paper_3 author_5 ...
i need create query returns information specific paper including co-authors of it. when try that, come table this:
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
i don't want repeating. need show citation information of paper, contained in many-to-many table authors , 2, table returns same information 12 times when paper has 3 co-authors , 4 citations. how can manage that? table helpful:
paper id paper name publication date co-author cited paper_1 asd 2013 author_2 paper_15 author_5 paper_22 author_7 paper_23 paper_25
or if have better idea table design, i'm open those. lot in advance.
i recommend keep initial result have...
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
if examine above, each row has paper id
identifier. result desire incomplete data, asking null data incomplete viewer.
paper id paper name publication date co-author cited 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
looking @ desired result, paper_25 there technically no data related cited by
row making redundant. sql language isn't built styling purposes, better off leaving such formatting spreadsheet program or website style sheets.
Comments
Post a Comment