2
Having the tables PRODUTO
, CATEGORIA
whereas a CATEGORY may have several PRODUCTS, would like a select
list in a column nvarchar all the PRODUCT NAME of a CATEGORY.
Something like:
select concat( select p.nome from categoria c
inner join produto p on c.id = p.fk_categoria
where c.id = categoria.id) as ProdutosDaCategoria from categoria
This code won’t work but it’s an attempt to explain what I need.
You would also have to put a "," or other separator character between each result of subquery
.
Someone knows how to do ?
Note: any solution that brings all the categories listed and the "name" of products concatenates in an nvarchar meets the problem (as long as the query is not unviable expensive ) .
Gave straight !!! Thank you very much !!!!!!!
– John Diego
You’re welcome, I’m glad you helped.
– bruno
Very cool ! I didn’t know that in for xml path if you put + 'algumastring' it stopped displaying the tags to display it in place , this will help a lot !!
– John Diego