group per SQL query

0

I have a post table with a category field, each post you enter can get more than one category:

post1 categoria1, categoria2
post2 categoria1, categoria3

How can I perform a sql query to join the duplicate categories and have a result like this:
categoria1, categoria2, categoria 3
instead of categoria1, categoria2, categoria1, categoria 3

SELECT post_category FROM posts group by post_category

result: Empresas, Ecônomia, ESPN, Ecônomia
I have only two posts each with 2 categories

    
asked by anonymous 28.02.2017 / 19:48

1 answer

-2

The most correct would be to have the following structure .. post category post1 category1 post1 category2 post2 category1 post2 category3 then you could easily list the different categories of each post .. but in this case by what I noticed is entering more than one category in the same field and all concatenated. But as the structure is already mounted you can use the function splifn of this link here and use the function to generate a table and thus bring the distinct of each post.

    
01.03.2017 / 14:16