在一张表中查询唯一值,并显示其它字段数据

刘德胜 3782次浏览

摘要:在一张表中查询唯一值,并显示其它字段数据SELECT s1.nameASname, s1.addtimeASaddtime FROM qianchengASs1 WHERE s1.idIN((selectmax(`s2`.`id`)from`qiancheng...

在一张表中查询唯一值,并显示其它字段数据
SELECT
s1.name AS name,
s1.addtime AS addtime
FROM
qiancheng AS s1
WHERE
s1.id IN ((select max(`s2`.`id`) from `qiancheng` `s2` where (`s1`.`name` = `s2`.`name`)))
ORDER BY
s1.id DESC