如图,我有 这样一份数据
字段比较多,大约有30个多字段.我想根据宝贝id 和 日期进行去重处理. 简单的说就是2列去重我查了一下distinct方法是去重的但是我执行了如下语句SELECT distinct 宝贝id FROM taobao.jutiliushi;
distinct
SELECT distinct 宝贝id FROM taobao.jutiliushi;
恩所有的字段都没了~,我不知道网上找到这种去重的方法有什么意义~
所以想问下,假如我想针对多个字段去重,同时又能保持表的结构?怎么处理?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
What you need isgroup by
group by
select * from taobao.jutiliushi group by 宝贝id;
select distinct id, date,....column name from table name
SELECT DISTINCT(baby id) AS id, date, baby title,... FROM table name;
You only selected the baby id, and of course the result will only be the baby id
SELECT * FROM (SELECT * FROM `表A` GROUP BY 去重字段1) as aa GROUP BY aa.去重字段2
What you need is
group by
select distinct id, date,....column name from table name
SELECT DISTINCT(baby id) AS id, date, baby title,... FROM table name;
You only selected the baby id, and of course the result will only be the baby id