3

I am using mysql , Table with 2 Columns

Col1  |  Col1 
------+-------+
a@a   |   ab  |
a@a   |   cd  |
b@b   |   ab  |
b@b   |   cd  |

I want result like this

Col1  |  Col1 
------+--------+
a@a   |   abcd |
b@b   |   abcd |

How can i achieve this using SQL please help me. Thanks.

1 Answer 1

2

Use GROUP_CONCAT with no SEPARATOR like so:

SELECT col1, GROUP_CONCAT(col2 SEPARATOR '') AS col2
FROM tablename
GROUP BY col1;

See it in action here:

This will give you:

| COL1 | COL2 |
---------------
|  a@a | abcd |
|  b@b | abcd |
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.