0

I have a mysql table that looks like this:

id    col2    col3      col4
1   value1    value2    3534
2   value1    value1    8456
3   value1    value2    3566
4   value1    value3    7345
5   value2    value3    6734

What I wanted to do is, select distinct col2+col3 values

id    col2    col3      col4
1   value1    value2    3534
2   value1    value1    8456
4   value1    value3    7345
5   value2    value3    6734

I used below query, I get desired result as shown here.

SELECT distinct(CONCAT(col2, col3)) as "dummy column", id, col2, col3, col4
FROM yourtable
GROUP BY CONCAT(col2, col3);

My question is,

As I don't want to display column "dummy column" in output table, how can I hide the same?

This question is related to SO older question

Selecting distinct 2 columns combination in mysql

Community
  • 1
  • 1
Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276

1 Answers1

0

Why aren't you trying the following?

SELECT id, col2, col3, col4
FROM yourtable
GROUP BY col2, col3
Ben
  • 51,770
  • 36
  • 127
  • 149
Sashi Kant
  • 13,277
  • 9
  • 44
  • 71