Reputation: 5196
I have a table in that I have 2 fields: Logid
and Type
:
+---------+---------+
| Logid | Type |
+---------+---------+
| 1 | PHP |
| 2 | Mysql |
| 3 | PHP |
| 4 | JAVA |
| 5 | PHP |
| 6 | MYSQL |
+---------+---------+
I need to get all Logid
by logs_operationtype
group,
I need to get the output as:
+------------+---------+
| Logid | Type |
+------------+---------+
| 1,3,5 | PHP |
| 2,6 | Mysql |
| 4 | JAVA |
+------------+---------+
Upvotes: 1
Views: 50
Reputation: 19882
SELECT
group_concat(Login) as LogId,
Type
FROM
myTable
GROUP BY Type
Upvotes: 1
Reputation: 47482
Use GROUP_CONCAT
SELECT GROUP_CONCAT(Logid) AS Logid, Type
FROM <tablename>
GROUP BY Type
Upvotes: 1