SoFunction
Updated on 2025-03-10

Summary of more practical SQL statements

id name 
1 a 
2 b 
3 c 
1 a 
2 b 
3 c 

The following SQL statements are all the above table mytable:

1. Query all data recorded with id=1,3 select * from mytable
where id in(1,3)
2. Delete the data with duplicate id, and only all data with id=1,2,3 remain in the table. Select * into # from mytable
truncate table mytable

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