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
table select distinct * from #
select * from table
#
3、建立一個新表 films_recent ,它的值包含來自表films
複製程式碼 程式碼如下:
SELECT * INTO films_recent FROM films