将记录排序为随机顺序 [英] Sort Records into a Random Order

查看:60
本文介绍了将记录排序为随机顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有办法做到这一点吗?谢谢。


Neil

Carol Wilson画廊的猫画
http://www.carolwilsongallery.com

Is there a way to do this? Thanks.

Neil
Cat Paintings At Carol Wilson Gallery
http://www.carolwilsongallery.com

推荐答案

假设您有一个主键字段名为MyID,请尝试:

SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);


Rnd()实际上不对主要做任何事情键,但是如果你没有传入它,那么查询优化器太聪明了,并且不会打扰每一行再次调用该函数的
。 br />

不要忘记在会议开始时发出一个随机数。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Nhmiller" < NH ****** @ aol.comnojunk>在消息中写道

news:20 *************************** @ mb-m19.aol.com。 ..
Assuming you have a primary key field named MyID, try:
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);

The Rnd() does not actually do anything with the primary key, but if you
don''t pass it in, the query optimizer is too intelligent and doesn''t bother
calling the function again on every row.

Don''t forget to issue a Randomize at the start of your session.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nhmiller" <nh******@aol.comnojunk> wrote in message
news:20***************************@mb-m19.aol.com...
有没有办法做到这一点?谢谢。

Neil
Carol Wilson画廊的猫画
http://www.carolwilsongallery.com
Is there a way to do this? Thanks.

Neil
Cat Paintings At Carol Wilson Gallery
http://www.carolwilsongallery.com



>假设您有一个名为MyID的主键字段,请尝试:
>Assuming you have a primary key field named MyID, try:
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);

Rnd()实际上并没有对主键执行任何操作,但如果你不赞成传入它,查询优化器太聪明了,并没有打扰在每一行再次调用该函数。

不要忘记在开始时发出一个Randomize你的会话。
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);

The Rnd() does not actually do anything with the primary key, but if you
don''t pass it in, the query optimizer is too intelligent and doesn''t bother
calling the function again on every row.

Don''t forget to issue a Randomize at the start of your session.




你能给我详细的指示,从哪个对象开始点击(我的b $ b假设它是查询)?谢谢。


Neil

Carol Wilson画廊的猫画
http://www.carolwilsongallery.com


1。确保你的表有一个AutoNumber主键。


2.在这个表中创建一个查询。


3.在Field字段中,输入:

Rnd([xxxx])

替换xxxx使用主键字段的名称。


4.在此下的排序行中,输入:

升序。


5.取消选中网格显示行中的此框。


6.查看查询的输出。


这将给你相同的结果系列,除非你告诉Access

randomize。为此:

1.单击Database窗口的Modules选项卡,然后单击New。

Access打开一个新模块。


2.输入:

公共函数初始化()

随机化

结束函数


3.使用诸如basInit之类的名称保存模块。关闭。


4.在数据库窗口的宏选项卡上,单击新建。

Access打开一个新宏。


5.在Action列中,选择RunCode。

在下方窗格中输入:

Init()


6.使用名称AutoExec保存宏。

名称很重要。


7.重新启动数据库。


现在每次打开这个数据库,随机发生器都会运行。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


" Nhmiller" < NH ****** @ aol.comnojunk>在消息中写道

news:20 *************************** @ mb-m16.aol.com。 ..
1. Make sure your table has an AutoNumber primary key.

2. Create a query into this table.

3. In The Field row, enter:
Rnd([xxxx])
replacing "xxxx" with the name of your primary key field.

4. In the Sorting row under this, enter:
Ascending.

5. Uncheck the box under this in the Show row of the grid.

6. View the output of your query.

This will give you the same seriese of results unless you tell Access to
randomize. To do that:
1. Click the Modules tab of the Database window, and click New.
Access opens a new module.

2. Enter:
Public Function Init()
Randomize
End Function

3. Save the module with a name such as basInit. Close.

4. On the Macro tab of the Database window, click New.
Access opens a new macro.

5. In the Action column, choose RunCode.
In the lower pane enter:
Init()

6. Save the macro with the name AutoExec.
The name is important.

7. Restart your database.

Now each time to you open this database, the randomizer will run.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Nhmiller" <nh******@aol.comnojunk> wrote in message
news:20***************************@mb-m16.aol.com...
假设您有一个名为MyID的主键字段,请尝试:
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);

Rnd()实际上并没有对主键做任何事情,但是如果你没有传递它,那么查询优化器太聪明了并且不会打扰
在每一行再次调用该函数。

不要忘记在会话开始时发出一个Randomize。
Assuming you have a primary key field named MyID, try:
SELECT * FROM MyTable ORDER BY Rnd(MyTable.MyID);

The Rnd() does not actually do anything with the primary key, but if you
don''t pass it in, the query optimizer is too intelligent and doesn''t
bother
calling the function again on every row.

Don''t forget to issue a Randomize at the start of your session.



你能不能给我详细的指示,从哪个对象开始点击
(我认为它是查询)?谢谢。

Neil
Carol Wilson画廊的猫画
http://www.carolwilsongallery.com



这篇关于将记录排序为随机顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆