标签:
一:
分页查询的时候 sql server使用的是top关键字,而mysql 使用的是limit
e.g:
查询第五个到第十个入职的职员
sql server2000:
select top 6 * from emp where empno not in (select top 4 empno from emp order by hiredate) order by hiredate;
mysql:
select * from emp order by hire date limit 4,6;
p.s: limit a 意思是前a条记录
limit a,b 意思是从第(a+1)条记录到第(a+b)条记录;如果b=-1,意思是从第(a+1)到最后一条记录;
二:
题目:如何删除掉一张表中重复的数据?
比如有一张表
create table cat (catId int,catName varchar(30));
insert into cat(1,‘aa‘);
此句执行九次;
insert into cat(2,‘bb‘);
此句执行九次;
sql server 版:4句话
select distinct * into cattemp from cat;
delete from cat;
insert into cat select * from cattemp;
drop table cattemp;
mysql 版:
create temporary table cattemp (select distinct * from cat);
delete from cat;
insert into cat select * from cattemp;
drop table cattemp;
sql server 与 mysql 分页查询以及创建临时表的区别
标签:
原文地址:http://www.cnblogs.com/stillunknown/p/4883177.html