比如一个表里面有多个张三、多个李四,我们调用数据时碰到重复的多个张三时只调一条数据,多个李四也只调一条数据。
1、原生sql方式
保留相同name值的最小id行 select * from table_a a where not exists ( select 1 from table_a b where b.name = a.name and b.id < a.id )
2、Thinkphp6方式
原文:https://www.cnblogs.com/phpyangbo/p/14276068.html