SQL 面试题

1.删除重复的信息
delete from fc_test1 where fc_sk in (
SELECT max(fc_sk) as fc_sk from FC_TEST1 group by spn_name,fmi_name having count(1)>1
)
2.select name from student group by name having min(score)>80;
3.delete from student where stu_id not in (select min(stu_id) from student group by name, age, grade)
4.select * into table from table_a where 1<>1;
select * into b from a where 1<>1 (where1=1,拷贝表结构和数据内容)
insert into b(a, b, c) select d,e,f from a;
5. 两张关联表,删除主表中已经在副表中没有的信息
delete from info where not exists (select * from info_back where info.id = info_back.id)
https://www.cnblogs.com/liyasong/p/sql_in_exists.html
http://www.sohu.com/a/206931104_100012573

https://www.cnblogs.com/deng-cc/p/6515166.html

你可能感兴趣的:(mysql)