Jose
Jose

Reputation: 73

Select distinct a row in Mysql

I have a database where I have two columns like you can see above. Note that the second line is equal to the first but the third is different as you can see

number_chip| Date_of_Scanned_chip
   345             2016-12-12
   345             2016-12-12
   345             2017-1-03 

The DISTINCT on the column (number_chip) eliminates all the chips and gives me only one

   number_chip| Date_of_Scanned_chip
       345             2016-12-12

But I want something that gives me this. Please help :)

number_chip| Date_of_Scanned_chip
       345             2016-12-12
       345             2017-1-03 //Eliminates the second line

Upvotes: 0

Views: 1076

Answers (2)

MackProgramsAlot
MackProgramsAlot

Reputation: 593

GROUP BY number_chip, Date_of_Scanned_chip;

Upvotes: -1

Gordon Linoff
Gordon Linoff

Reputation: 1269483

The DISTINCT on the column (number_chip) eliminates all the chips and gives me only one

I cannot imagine what you mean by this. A simple query:

select distinct number_chip, Date_of_Scanned_chip
from t;

seems to do exactly what you want to do. select distinct is a statement in SQL. There is no distinct in SQL that operates on one column.

Upvotes: 2

Related Questions