2

I have a query in mysql that it's result is as below:

val1_col1A  val1_col2A  val1_col1B val1_col2B
val1_col1A  val1_col2A  val2_col1B val2_col2B
val1_col1A  val1_col2A  val3_col1B val3_col2B

like this :

1 reza math 20
1 reza c++  19
1 reza C#   17

my query is :

SELECT col1A,col2A,col1B,col2B
FROM  A join B
ON col3A=col3B

I want to have a query that it result be as below :

val1_col1A  val1_col2A  val1_col1B,val2_col1B,val3_col1B val1_col2B,val2_col2B,val3_col2B

Like this :

1 reza math,c++,c# 20,19,17

1 Answer 1

1

I think this is what you are looking for:

SELECT CONCAT(GROUP_CONCAT(DISTINCT val1_col1A), 
              GROUP_CONCAT(DISTINCT val1_col2A), 
              GROUP_CONCAT(DISTINCT val1_col1B),
              GROUP_CONCAT(DISTINCT val1_col2B)) AS value
FROM table_name;
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.