I have a table for example citations
that contains:
paperkey
1
2
and another table source
that contains
paperkey | authors
1 a
1 b
1 c
2 d
2 e
3 x
5 y
6 z
6 a
The paperkey
in table citation
is the subset of paperkey
in source
table. So I need to take the authors
of paperkey
in table citation. My expected output is:
1 a
1 b
1 c
2 d
2 e
I tried but I could not find the relevant query. Currently I have the query:
select a.paperkey, groupconcat(b.authors)
from citations a
left join source b
on a.paperkey = b.paperkey
group by a.paperkey;
but the result is
1 a,b,c
2 d,e
This is the best I could do. But I needed to produce the output I expected so that the authors are printed in different rows and I could not find any query that works like that.
You shouldn't have to have the need to group the results, you should just need to order the results like this:
select a.paperkey, b.authors
from citations a
left join source b using(paperkey)
order by b.paperkey, b.authors;
I personally would us using, since the column names are the same.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments