在实际应用中,数据库中表的记录可能非常多,经常会想知道是否有多条记录的某个字段值是一样的,sql语句如下:
select * from tms_mer where merid in(select merid from tms_mer group by merid having count(*)>1);
或者:
select merid,count(1) from tms_mer m group by m.merid having count(1)>1;