一:
分页查询的时候 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;
时间: 2024-09-30 06:54:54