请大家帮忙:怎么样用SQL语句查询一个表的前十条记录?
例如:select * from csdn where asp=1 order by xml desc
假如现在查到了50条,但是我要前10条,怎么办?
12 个解决方案
#1
select top 10 * from csdn where asp=1 order by xml desc
#2
select top 10 * from csdn where asp=1 order by xml desc
#3
"select top 10 * from xw"
#4
select top10 * from csdn where asp=1 order by xml desc
#5
select top10 * from csdn where asp=1 order by xml desc
#6
select top 10 * from csdn where asp=1 order by xml desc
#7
如果你想做分页就要定程序了,如果不是则
select top 10 * from csdn where asp=1 order by xml desc
select top 10 * from csdn where asp=1 order by xml desc
#8
select top 10 * from csdn where asp=1 order by xml desc
同意这个
同意这个
#9
select * from csdn where asp=1 and rownum <=10 order by xml desc
在oracle里面用的
在oracle里面用的
#10
select top 10 * from csdn where asp=1 order by xml desc
#11
select top 10 * from csdn where asp=1 order by xml desc
#12
如果是access数据库,那样是不行的。
如果第10个与第11个xml值相同,则会查询出11条记录。
如果有自动编号的话可以:
select top 10 * from csdn where asp=1 order by xml desc,自动编号
如果是ms sql就一定10条了。
如果第10个与第11个xml值相同,则会查询出11条记录。
如果有自动编号的话可以:
select top 10 * from csdn where asp=1 order by xml desc,自动编号
如果是ms sql就一定10条了。
#1
select top 10 * from csdn where asp=1 order by xml desc
#2
select top 10 * from csdn where asp=1 order by xml desc
#3
"select top 10 * from xw"
#4
select top10 * from csdn where asp=1 order by xml desc
#5
select top10 * from csdn where asp=1 order by xml desc
#6
select top 10 * from csdn where asp=1 order by xml desc
#7
如果你想做分页就要定程序了,如果不是则
select top 10 * from csdn where asp=1 order by xml desc
select top 10 * from csdn where asp=1 order by xml desc
#8
select top 10 * from csdn where asp=1 order by xml desc
同意这个
同意这个
#9
select * from csdn where asp=1 and rownum <=10 order by xml desc
在oracle里面用的
在oracle里面用的
#10
select top 10 * from csdn where asp=1 order by xml desc
#11
select top 10 * from csdn where asp=1 order by xml desc
#12
如果是access数据库,那样是不行的。
如果第10个与第11个xml值相同,则会查询出11条记录。
如果有自动编号的话可以:
select top 10 * from csdn where asp=1 order by xml desc,自动编号
如果是ms sql就一定10条了。
如果第10个与第11个xml值相同,则会查询出11条记录。
如果有自动编号的话可以:
select top 10 * from csdn where asp=1 order by xml desc,自动编号
如果是ms sql就一定10条了。