tags:

views:

25

answers:

2

a table:

+-----+-----+----+ 
| Sym | Pos | Id | 
+-----+-----+----+ 
| a   | 0   | 0  | 
| b   | 1   | 0  | 
| c   | 2   | 0  | 
| a   | 0   | 1  | 
| d   | 1   | 1  | 
| b   | 0   | 2  | 
+-----+-----+----+ 

need to build from this table row by Id, that would be followed in order Sym Pos. In this case, that would have:

+-----+-----+----+ 
| str | Pos | Id | 
+-----+-----+----+ 
| abc | 0   | 0  | 
| ad  | 0   | 1  | 
| b   | 0   | 2  | 
+-----+-----+----+

Thanks!

+1  A: 

Have a look at using GROUP_CONCAT()

astander
+2  A: 

Use GROUP BY and the MySQL specific aggregate function GROUP_CONCAT:

SELECT GROUP_CONCAT(Sym ORDER BY Pos SEPARATOR '') AS str, Id
FROM yourtable
GROUP BY id
Mark Byers
Thanks. it works!
Zoitc2014