Sign-up....

进来接分!

我遇到一个问题,每一次表单提交插入数据库的时候,要把数据库里70%的记录中的SUIJI字段设成"yes",其他的设成"no",这70%记录必须是随机的,请问有什么高效的方法呀。

我现在用的方法要判断和遍历数据库好几次,增加了服务器的负载,再线等

[124 byte] By [msdn] at [2007-8-14 9:13:10]
# 1 Re: 进来接分!

分3步骤,无需判断!

1.设置所有记录为yes(这个简单吧)

2.随即选择30%的记录的记录ID

3.设置步骤2中得到的记录ID的记录为no

ShiningstarHu at 2005-4-1 15:55:48 >
# 2 Re: 进来接分!

同意楼上说法

raas at 2005-4-1 15:58:49 >
# 3 Re: 进来接分!

关注一下。

myvicy at 2005-4-1 16:23:47 >
# 4 Re: 进来接分!

TO ShiningstarHu(Shining_star)

不判断我怎么知道他达到了30%,能把代码写出来吗?

loverworld at 2005-4-1 16:30:46 >
# 5 Re: 进来接分!

没有人回答!自己哪小号顶了。

worldlover at 2005-4-1 17:29:14 >
# 6 Re: 进来接分!

没有人回答!自己哪小号顶了

worldlover at 2005-4-1 17:39:03 >
# 7 Re: 进来接分!

没有人回答!自己哪小号顶了

worldlover at 2005-4-1 17:39:10 >
# 8 Re: 进来接分!

TO ShiningstarHu(Shining_star)

不判断我怎么知道他达到了30%,能把代码写出来吗?

loverworld at 2005-4-1 17:49:08 >
# 9 Re: 进来接分!

access的模块里建个函数,不太清楚asp怎么调用,可能是存储过程方式。

mjpclab at 2005-4-1 18:23:07 >
# 10 Re: 进来接分!

(0---0.3)*记录数。

winstarr at 2005-4-1 18:31:45 >
# 11 Re: 进来接分!

update tb set SUIJI='no' where id in (select top 30 percent id from tb order by newid())

madpolice at 2005-4-1 18:46:33 >
# 12 Re: 进来接分!

顶一下哈!!

tyhn168 at 2005-4-1 19:47:39 >
# 13 Re: 进来接分!

update tb set SUIJI='no' where id in (select top 30 percent id from tb order by newid())

madpolice() 经典的SQL语句,佩服,Up

楼主结贴,等啥呢?

cfstock at 2005-4-1 21:51:37 >
# 14 Re: 进来接分!

就是来帮你顶一顶的!呵呵!娃娃鱼

thhaozi at 2005-4-1 22:26:12 >
# 15 Re: 进来接分!

在顶!

thhaozi at 2005-4-1 22:27:31 >
# 16 Re: 进来接分!

我顶下~本人不会~

mid7576535 at 2005-4-2 9:47:40 >
# 17 Re: 进来接分!

update tb set SUIJI='no' where id in (select top 30 percent id from tb order by newid())

________________________________________________________

newid()是SQL自带的存储过程吗?直接用就行了吗?

loverworld at 2005-4-2 14:28:44 >
# 18 Re: 进来接分!

update tb set SUIJI='no' where id in (select top 30 percent id from tb order by newid())

________________________________________________________

newid()是SQL自带的存储过程吗?是的话,他的功能是什么呀?直接用就行了吗?

loverworld at 2005-4-2 15:42:52 >
# 19 Re: 进来接分!

强烈关注

dwb0328 at 2005-4-2 16:45:32 >
# 20 Re: 进来接分!

大虾些,告诉小弟了,我等的好累呀!!!

loverworld at 2005-4-2 18:18:13 >
# 21 Re: 进来接分!

调试下就行了呀

shenlan198263 at 2005-4-2 21:30:28 >

Web

All Classified