SQL 实用语句
更新时间:2009年06月19日 23:34:36 作者:
以下的sql语句都以上面表mytable为准
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
insert table select distinct * from #
select * from table
drop table #
3、创建一个新表 films_recent ,它的值包含来自表films
SELECT * INTO films_recent FROM films
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
insert table select distinct * from #
select * from table
drop table #
3、创建一个新表 films_recent ,它的值包含来自表films
复制代码 代码如下:
SELECT * INTO films_recent FROM films
相关文章
sql server中的decimal或者numeric的精度问题
在sql server中定义列的数据类型decimal时需要制定其精度和小数位数。2009-05-05


最新评论