1

I need to SELECT from a db and don't show rows that are identical in SOME rows (or actually hide the rows that are identical to eachother except 1 item...)

Let's give an example:

ID C1 C2 C3
1  3  3  4
1  5  5  4
1  2  3  4
1  6  5  4
1  2  3  4

After SELECT i want:

ID C1 C2 C3
1  X  3  4
1  X  5  4

where "X" has no importance...i have to show that column but i don't care which one is shown.

Is this possible with a simple SELECT query?

To sum up, if i ask the question regarding this specific example, What can i do to SELECT from that table and show only one of the rows if it has identical duplicates in ID, C2 and C3?

SIDENOTE: this MYSQL: SELECT Method - but don't show duplicates / GROUP or DISTINCT? doesn't help.

Community
  • 1
  • 1
ndelucca
  • 517
  • 1
  • 8
  • 20

1 Answers1

1

Have you tried GROUP BY?

SELECT Id, MAX(C1), C2, C3
FROM SomeTable
GROUP BY Id, C2, C3

Since you don't care about C1, in this query, I get the largest C1 value.

Eric
  • 3,165
  • 1
  • 19
  • 25
  • i have a lot to learn about mySql..... this is something basic and i didn't know about it. Thank you it helped me a lot. – ndelucca Mar 09 '17 at 13:51