MySQL Forums
Forum List  »  Newbie

Re: Simple SQL Question
Posted by: Peter Brawley
Date: August 27, 2017 05:00PM

Usually, p I'm having a hard time relating the examples to my specific situation

The first method given is dead simple, a whole lot easier than trying to port SQL Server syntax to MySQL ...

select a.patent_id, group_concat(b.assignee_id)
from patent a
join assignee b using(patent_id)
group by a.patent_id;

Pivot tables are used to tabulate statistics for categories (years, months, departments &c) that are known before the query runs.

You're not aggregating, just tabulating, so if Group_Concat() is not a tidy enough solution for you, that is, you want separate column results, you'll need to query the assignee table in advance for the maximum no. of assignees a patent_id has, and write the query to return that many assignee columns.

Options: ReplyQuote

Written By
August 26, 2017 11:56PM
August 27, 2017 08:50AM
August 27, 2017 11:59AM
Re: Simple SQL Question
August 27, 2017 05:00PM
August 27, 2017 06:21PM
August 27, 2017 06:38PM
August 27, 2017 07:14PM
August 27, 2017 08:20PM
September 07, 2017 02:38AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.