在MYSQL中使用SELECT DISTINCT [英] Using SELECT DISTINCT in MYSQL

查看:94
本文介绍了在MYSQL中使用SELECT DISTINCT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

曾经做过很多搜索,但还没有真正找到我的MYSQL问题的答案.

Been doing a lot of searching and haven't really found an answer to my MYSQL issue.

SELECT DISTINCT name, type, state, country FROM table

结果为1,795条记录

Results in 1,795 records

SELECT DISTINCT name FROM table

结果为1,504条记录

Results in 1,504 records

对于每个重复的名称" ...类型",州",国家"在每个记录中都不匹配.

For each duplicate "name"... "type", "state", "country" aren't matching in each record.

试图弄清楚如何将关联的行选择为DISTINCT名称,而不检查它们是否为DISTINCT

Trying to figure out how to SELECT the associated row to the DISTINCT name, without checking them for being DISTINCT or not

推荐答案

SELECT name, type, state, country FROM table GROUP BY name;

应该可以解决问题.

这篇关于在MYSQL中使用SELECT DISTINCT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆