Member Avatar for jward50

Hi
I wonder if anyone can help
I have a query

SELECT b.name,c.name
FROM directory_organisation_area_of_interest a, directory_organisation b, directory_areaofinterest c
where b.id = a.organisation_id
and a.areaofinterest_id = c.id

which returns multiple rows per organisation however I would like to be able to have one row per org with multiple colums for all of the areas of interest which could be up to about 20 or so.

Many thanks in advance

You cannot have that (columns acting as rows) in standard SQL. You will have to walk through the result set and format a report based on grouping by organization.
In MySQL you can maybe make use of the group_concat() function: group by organization and concatenate the areas of interest in one column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.