简体   繁体   English

在MySQL中选择不同的行

[英]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)上的DISTINCT消除了所有筹码,只给了我一个

   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

The DISTINCT on the column (number_chip) eliminates all the chips and gives me only one 列(number_chip)上的DISTINCT消除了所有筹码,只给了我一个

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. select distinct是SQL中的一条语句。 There is no distinct in SQL that operates on one column. 在SQL上没有distinct可对一列进行操作。

GROUP BY number_chip,Date_of_Scanned_chip;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM