Skip to content
Advertisement

GROUP_CONCAT in SQLite

I am having data like this

by using this query

Now, I want to show data like this

and so on..I also know it can achieve by GROUP_CONCAT function. So, I tried with this

But, It shows me error. So, what I am doing wrong here. What are the right procedure to achieve that?

Advertisement

Answer

You need to add GROUP BY clause when you are using aggregate function. Also use JOIN to join tables.

So try this:

See this sample SQLFiddle


What you were trying was almost correct. You just needed to add GROUP BY clause at the end. But the first one is better.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement