SQL 實(shí)用語(yǔ)句
更新時(shí)間:2009年06月19日 23:34:36 作者:
以下的sql語(yǔ)句都以上面表mytable為準(zhǔn)
id name
1 a
2 b
3 c
1 a
2 b
3 c
以下的sql語(yǔ)句都以上面表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)建一個(gè)新表 films_recent ,它的值包含來(lái)自表films
SELECT * INTO films_recent FROM films
1 a
2 b
3 c
1 a
2 b
3 c
以下的sql語(yǔ)句都以上面表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)建一個(gè)新表 films_recent ,它的值包含來(lái)自表films
復(fù)制代碼 代碼如下:
SELECT * INTO films_recent FROM films
相關(guān)文章
SQL Server實(shí)現(xiàn)顯示每個(gè)類別最新更新數(shù)據(jù)的方法
這篇文章主要介紹了SQL Server實(shí)現(xiàn)顯示每個(gè)類別最新更新數(shù)據(jù)的方法,涉及SQL Server數(shù)據(jù)庫(kù)Select查詢操作使用技巧,需要的朋友可以參考下2017-03-03
sqlserver 中時(shí)間為空的處理小結(jié)
sql server中常常需要使用DateTime類型的字段。當(dāng)此類型字段值為空時(shí),常常出現(xiàn)各種異常2011-10-10
SQL Server2008數(shù)據(jù)庫(kù)導(dǎo)入導(dǎo)出兼容性處理方案
SQL Server 的高版本數(shù)據(jù)庫(kù)恢復(fù)到低版本則可能會(huì)有兼容性問(wèn)題,下面為大家介紹的是如何解決此類問(wèn)題2014-05-05
sql server中的decimal或者numeric的精度問(wèn)題
在sql server中定義列的數(shù)據(jù)類型decimal時(shí)需要制定其精度和小數(shù)位數(shù)。2009-05-05

