Subject | Re: [ib-support] select Random-records |
---|---|
Author | raptor |
Post date | 2001-09-07T15:30:16Z |
:") ok... I want to use this so that i can display randomly ads on the
web-pages (from all available).... curently I use something like code below
which get's all ID's into perl script which is not very effective.. and has
the drawback of not been very random (of cource it can be done more random
but will be slower)...
my $res = $p{dbh}->selectall_arrayref($p{query}, {Slice=>{}} ) or dbiError;
if ($res) {
foreach my $ary (@$res[ map int(rand $#$res), 1 .. $p{count} ] ) {
... do something ....
};
};
so it will better if I do this in the DB.
cheers..
=====
iVAN
raptor@...
=====
| At 02:30 PM 9/7/2001 +0300, raptor wrote:
|
| >I want to say give me Y-count records (from just one table, not
| >a join or something), but want these records to be choosed on Random
| >principe ... keep in mind that the ID's are not guaranteed to be
| >sequental... i.e there can be holes in sequence ( u know generators
:") ).
|
| What on earth are you doing?
|
|
| Regards,
|
| Ann
| www.ibphoenix.com
| We have answers.
]- and I have the questions :"))
web-pages (from all available).... curently I use something like code below
which get's all ID's into perl script which is not very effective.. and has
the drawback of not been very random (of cource it can be done more random
but will be slower)...
my $res = $p{dbh}->selectall_arrayref($p{query}, {Slice=>{}} ) or dbiError;
if ($res) {
foreach my $ary (@$res[ map int(rand $#$res), 1 .. $p{count} ] ) {
... do something ....
};
};
so it will better if I do this in the DB.
cheers..
=====
iVAN
raptor@...
=====
| At 02:30 PM 9/7/2001 +0300, raptor wrote:
|
| >I want to say give me Y-count records (from just one table, not
| >a join or something), but want these records to be choosed on Random
| >principe ... keep in mind that the ID's are not guaranteed to be
| >sequental... i.e there can be holes in sequence ( u know generators
:") ).
|
| What on earth are you doing?
|
|
| Regards,
|
| Ann
| www.ibphoenix.com
| We have answers.
]- and I have the questions :"))