Help with an SQL query

12 views
Skip to first unread message

fur...@gmail.com

unread,
Nov 5, 2013, 3:03:29 PM11/5/13
to bib...@googlegroups.com
Hi,

Wondering if someone could help me with a mysql query that would return the just the links field from the works table where the work has at least one author from a specified group.

Thanks.

Howard Ding

unread,
Nov 5, 2013, 6:17:26 PM11/5/13
to bib...@googlegroups.com
I don't know via sql, but you should be able to do it fairly easily (if
less efficiently) via the rails console:

group = Group.find group_id #or however you can best find the group
you're interested in
contributorships = group.people.collect {|p| p.contributorships}.flatten
authorships = contributorships.select {|c| c.role == "Author"}
works = authorships.collect {|a| a.work}.uniq
links = works.collect {|w| w.links}
#now do whatever with the links

Howard
> --
> You received this message because you are subscribed to the Google
> Groups "bibapp" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bibapp+un...@googlegroups.com.
> To post to this group, send email to bib...@googlegroups.com.
> Visit this group at http://groups.google.com/group/bibapp.
> For more options, visit https://groups.google.com/groups/opt_out.

fur...@gmail.com

unread,
Nov 6, 2013, 2:14:09 PM11/6/13
to bib...@googlegroups.com
Thanks Howard.  Much appreciated.
Reply all
Reply to author
Forward
0 new messages