GROUP BY grouping data from another column into another column

Asked

Viewed 26 times

-1

all right? I need a help, I will explain below what I am doing and what I need:

I am developing for a digital advertising agency an automatic e-mail system that contains all the campaigns and formats that a service has in the air of the given month for example, however, I need to group the formats in a single campaign.

Down as the values come:

CAMPAIGN X

FORMAT 1

CAMPAIGN X

FORMAT 2

CAMPAIGN X

FORMAT 3

What I need:

CAMPAIGN X

FORMAT 1

FORMAT 2

FORMAT 3

How can I do this in SQL?

  • 2

    Post the structures of your tables which, depending on this, can be something extremely simple. It can be: CAMPAIGN X FORMAT 1 FORMAT 2 FORMAT 3?

  • SQL does not resolve , this has to be solved in the display layer.

2 answers

0

Thanks guys, I solved it in a different way... I made a GROUP_CONCAT in the fields I needed and in the end I used GROUP BY campaign, and after that I did a go with all the information I needed, and it worked!

0

SELECT campanha, formato FROM tabela GROUP BY campanha

This is what you can answer for the amount of information you have passed. Try to elaborate the question better or put the structure of your table. And the question doesn’t seem related to php.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.