0
I have a table post with a field category, each post that is inserted may receive more than one category:
post1 categoria1, categoria2
post2 categoria1, categoria3
how can I perform an 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
postsgroup by post_category
outworking: Empresas, Ecônomia, ESPN, Ecônomia
I have only two posts each with 2 categories
Could you post an example of SQL that you are using so that other users can use it as a basis to formulate a good answer? I already say that the first thing I thought of as a solution is to add a
DISTINCT
in hisSELECT
.– Victor Stafusa
I think that
DISTINCT
won’t work because the categories are within the same field, don’t know much about mysql, just simple searches– Hebert Lima
Is this column multivariate and in the first normal form? If it is, then this is going to be complicated. If it is not, then explain it better as it is. See more details at the beginning of this answer: http://answall.com/a/151394/132
– Victor Stafusa
yes, it’s multivariate, in which case I’ll create another table
– Hebert Lima