Say I got a table called Employee and it has 2 fields, EmployeeID and EmployeeName.
Now what I want is to do a query and find all those same names and concat their EmployeeIDs into a field.
Example:
Jon Wong EmpID: 5503
Jason Lim EmpID: 9223
Jon Wong EmpID: 5523
Jason Lim EmpID: 4533
Julia Wong EmpID: 4253
Jon Wong EmpID: 9943
I want to get below:
Jason Lim 9223###4533
Jon Wong 5503###5523###9943
Julia Wong 4253
I am currently doing the name checking and concat part in php. As a result, I cannot use mysql paging as the resultset should only be the distinct names.
Now, the number of records is getting larger and I need to find a way to do all that in queries so I can use mysql paging (offsets) for faster processing.
Can anyone help me?
I found this site http://www.dotnetsurfers.com/Blog/2008/01/16/ConcatenatingRowsInATableIntoASingleStringUsingSql.aspx and it is doing what I want but it's Oracle specific. I want mysql specific codes.
It's OK. I found group_concat() and it works.