SQL 實(shí)用語句
更新時間:2009年06月19日 23:34:36 作者:
以下的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
1 a
2 b
3 c
1 a
2 b
3 c
以下的sql語句都以上面表mytable為準(zhǔn):
1、查詢id=1,3記錄的所有數(shù)據(jù)
復(fù)制代碼 代碼如下:
select * from mytable where id in(1,3)
2、刪除id重復(fù)的數(shù)據(jù),表中數(shù)據(jù)只剩下id=1,2,3的所有數(shù)據(jù)
復(fù)制代碼 代碼如下:
select * into # from mytable
truncate table mytable
insert table select distinct * from #
select * from table
drop table #
3、創(chuàng)建一個新表 films_recent ,它的值包含來自表films
復(fù)制代碼 代碼如下:
SELECT * INTO films_recent FROM films
相關(guān)文章
SQL Server實(shí)現(xiàn)顯示每個類別最新更新數(shù)據(jù)的方法
這篇文章主要介紹了SQL Server實(shí)現(xiàn)顯示每個類別最新更新數(shù)據(jù)的方法,涉及SQL Server數(shù)據(jù)庫Select查詢操作使用技巧,需要的朋友可以參考下2017-03-03
SQL Server2008數(shù)據(jù)庫導(dǎo)入導(dǎo)出兼容性處理方案
SQL Server 的高版本數(shù)據(jù)庫恢復(fù)到低版本則可能會有兼容性問題,下面為大家介紹的是如何解決此類問題2014-05-05
sql server中的decimal或者numeric的精度問題
在sql server中定義列的數(shù)據(jù)類型decimal時需要制定其精度和小數(shù)位數(shù)。2009-05-05

