Sql以id为维度,选不重复的

Sql以id为维度,选择不重复信息,列出SQL语句如下:方案一:distinctselectdistinctnamefromtable方案二:groupbyselectmin(fid),name,sexfromtablegroupbyname方案三:select*fromtablewherenamein(selectnamefromtablegroupbynamehavingcount(name)=2)以上三个语句,可以过滤掉sql数据库中不重复的信息。

sql两张表怎么查询不重复的记录

SQL查询唯一记录可以使用countgroupby组合

首先查询唯一数据的ID,使用count()计算出只有数字1为唯一数据

selectb.*fromtablebwhereb.idin(selecta.idfromtableagroupbya.namewithcount(a.id)<2>