比较实用SQL语句总结

网络编程 2021-07-05 16:49www.168986.cn编程入门
sql语句查询,比较实用的技巧
id name 
1 a 
2 b 
3 c 
1 a 
2 b 
3 c 

以下的sql语句都以上面表mytable为准:

1、查询id=1,3记录的所有数据 select * from mytable
where id in(1,3)
2、删除id重复的数据,表中数据只剩下id=1,2,3的所有数据 select * into # from mytable
truncate table mytable

insert table select distinct * from # 
select * from table 
drop table #

Copyright © 2016-2025 www.168986.cn 狼蚁网络 版权所有 Power by