sql根据某个字段查找所有值 但是指定去重某几个字段 怎么写??

sql根据某个字段查找所有值 但是指定去重某几个字段 怎么写??

select distinct name, id from Data

图片说明
例如穿进去cid=1得到bid tid一组中不能有重复的

FSFSDSGDFGFDGDF

select distinct bid,tid from 表名 where cid=1;

select * from tablename where cid='1' and (tid,bid) in
(select tid,bid from tablename where cid='1' group by tid,bid having count(1)<2)

http://www.w3school.com.cn/sql/sql_distinct.asp,我在W3C上找到了你描述的问题的解决方案,可以去参考着来。

select * from tablename where cid='1' and (tid,bid) in
(select tid,bid from tablename where cid='1' group by tid,bid having count(1)<3)

select distinct bid

SELECT * FROM 表名 where id IN( SELECT MAX(id) FROM 表名 GROUP BY user_id)

SELECT bid FROM table WHERE cid = 1 GROUP BY bid

SELECT DISTINCT bid FROM table WHERE cid = 7

select * from tablename where cid='1' and (tid,bid) in
(select tid,bid from tablename where cid='1' group by tid,bid having count(1)<5)

你这个问题我之前也碰到了,并已经写成博客,请移步参考:mysql查询根据部分字段去重

解决如图问题:

select distinct bid,tid from 表名 where cid=1

你说tid,bid去重那别的字段该如何保留呢?你这说的根本没法写SQL啊。