0

I have table structure like this-

 Code Codelang Name 14 de David 14 en Michel 14 es John 

I want to show this table as-

 Code Name 14 [:de]David[:en]Michel[:es]John[:] 

Is it possible to do this using Group_Concat() or is there any other way to do this.?

1
  • This is, at best, a very strange task to ask of the database. Perhaps it's a manipulation that you should perform in the presentation layer of your application (i.e. in the program code that accesses MySQL)? Commented Mar 4, 2015 at 17:37

1 Answer 1

1
SELECT code, GROUP_CONCAT(CONCAT('[:',codelang,']',name) SEPARATOR '') as name FROM table1 GROUP BY code 

to get [:] at the end you can try:

SELECT code, CONCAT(GROUP_CONCAT(CONCAT('[:',codelang,']',name) SEPARATOR ''),'[:]') as name FROM table1 GROUP BY code 
Sign up to request clarification or add additional context in comments.

4 Comments

hello thanks Alex for reply. using your code I am getting this- [:de]David[:en]Michel[:es]John it is missing [:] at the end.
What will be the mysql query if I want to copy this column data to another column.? I have got follwing structure after applying above query. Code Nombre 14 [:de]David[:en]Michel[:es]John[:]
I don't understand... why do you need data to be copied using sql?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.