SQL 實(shí)用語句

以下的sql語句都以上面表mytable為準(zhǔn)

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

以下的sql語句都以上面表mytable為準(zhǔn):

1、查詢id=1,3記錄的所有數(shù)據(jù)
代碼如下:
select * from mytable where id in(1,3)

2、刪除id重復(fù)的數(shù)據(jù),表中數(shù)據(jù)只剩下id=1,2,3的所有數(shù)據(jù)
代碼如下:
select * into # from mytable
truncate table mytable

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

3、創(chuàng)建一個新表 films_recent ,它的值包含來自表films
代碼如下:
SELECT * INTO films_recent FROM films

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊11 分享