I was stuck in the following issue. Issue was related with retrieving common records in group. I have to display records which are common with each id.
Following records are inserted into the table "mytable":
id | title
-------+--------------------
16 | Apple
16 | Ball
16 | Cat
16 | Dog
18 | Eagle
18 | Fish
20 | God
20 | House
41 | India
41 | Jug
41 | Kite
I want the Output should be shown like this below:
id | title
-------+------------------
16 | Apple
| Ball
| Cat
| Dog
18 | Eagle
| Fish
20 | God
| House
41 | India
| Jug
| Kite
This issue is resolved now and solution to this problem is as follows:
Just write the query:
SELECT id,GROUP_CONCAT(title separator '\n') FROM mytable GROUP BY id
All done...
Thanks for reading this post.
0 Comment(s)