I am developing a school project in asp.net and I was trying to get a query, that results in several lines (which is corret), to show the results for each "result" on only one row, the thing is that the project is a web page to sell games. Each of the games has several developper, Genres(Action, FPS etc.), formats (digital or physical), platforms (ps3, ps4 etc.) and other setting like these. I tested it and It returns several rows, as I said before, that could be synthesised into a single row with several values in which the columns repeat.
Here is the query:
SELECT
dbo.Jogos.NomeJogo AS Jogo,
dbo.Plataforma.Plataforma,
dbo.Jogos.disponibilidade,
dbo.Jogos.Preco AS Preço,
dbo.Jogos.Stock,
dbo.Desenvolvedora.NomeDesenvolvedora AS Desenvolvedora,
dbo.PEGI.PEGI,
dbo.Formato.Formato,
dbo.Genero.Genero,
dbo.Fornecedor.NomeFornecedor AS Fornecedor
FROM dbo.Jogos
INNER JOIN dbo.Desenvolvedora ON dbo.Jogos.IdDesenvolvedora = dbo.Desenvolvedora.IdDesenvolvedora
INNER JOIN dbo.PEGI ON dbo.Jogos.IdPegi = dbo.PEGI.IdPEGI
INNER JOIN dbo.GeneroJogo ON dbo.Jogos.IdJogo = dbo.GeneroJogo.IdJogo
INNER JOIN dbo.Genero ON dbo.GeneroJogo.IdGenero = dbo.Genero.IdGenero
INNER JOIN dbo.JogosFormato ON dbo.Jogos.IdJogo = dbo.JogosFormato.IdJogo
INNER JOIN dbo.Formato ON dbo.JogosFormato.IdFormato = dbo.Formato.IdFormato
INNER JOIN dbo.JogosFornecedor ON dbo.Jogos.IdJogo = dbo.JogosFornecedor.IdJogo
INNER JOIN dbo.Fornecedor ON dbo.JogosFornecedor.IdFornecedor = dbo.Fornecedor.IdFornecedor
INNER JOIN dbo.JogosPlataforma ON dbo.Jogos.IdJogo = dbo.JogosPlataforma.IdJogo
INNER JOIN dbo.Plataforma ON dbo.JogosPlataforma.IdPlataforma = dbo.Plataforma.IdPlataforma
The query returns several lines for the same game which could be resumed to only one.
For example:
Game | Genre | Platform | Developper
___________________________________________________________
Assassin's Creed | Action | Ps3 | Ubisoft
Assassin's Creed | Stealth | Ps3 | Ubisoft
Assassin's Creed | Action | xBox 360 | Ubisoft
I'd like to obtain something like:
Game | Genre | Platform | Developper
_____________________________________________________________________
Assassin's Creed | Action, Stealth | Ps3, Xbox 360 | Ubisoft
I'm asking for assistance because I don't see how this could be possible.
Any help would be appreciated.
P.S.: A few values on the query are in Portuguese. I've also checked this thread How to use GROUP BY to concatenate strings in SQL Server? But this one uses only one table and I'm fetching data from several tables so I really don't know how to proceed in this one.
Thank you in advance Best regards, Kevin