mysql知识点回顾与梳理
一、sql语句执行顺序 from join on where group by avg,sum,count等各种函数 having select distinct order by(asc(升序),desc(降序)) LIMIT 二、如何获取表记录,或者某字段不同值个数 select count(distinct a.user_id) as cnt from table a 三、如何在sql表(假设为表a)中删除重复行 方法1: stp1:筛选出不重复的表记录 select distinct a.* from a stp2:将记录插入到临时表b中 insert into b select distinct a.* from a stp3:清空表a truncate table a stp4:将临时表数据插入表a insert into a select * from b 方法2: delete from a where (a.col_1,a.col_2) in ( select col_1,col_2 from a group by col_1,col_2 having count(*) > 1) and rowid not in (select min (rowid) a vitae group by col_1,col_2 having count(*)>1) 四、My Sql