>-Original Message-
>From: Rob Wultsch [mailto:[EMAIL PROTECTED]
>Sent: Monday, May 19, 2008 11:20 AM
>To: Jerry Schwartz
>Cc: Scott Haneda; mysql@lists.mysql.com
>Subject: Re: improving random record selection
>
>On Mon, May 19, 2008 at 7:24 AM, Jerry Schwartz
&g
On Mon, May 19, 2008 at 7:24 AM, Jerry Schwartz
<[EMAIL PROTECTED]> wrote:
> I might not understand what this is doing, but I think it will preferentially
> sample the ids that are at the end of a gap.
What don't you understand about the query or the way I described it?
> You say you want a "fla
>-Original Message-
>From: Rob Wultsch [mailto:[EMAIL PROTECTED]
>Sent: Saturday, May 17, 2008 6:47 PM
>To: Scott Haneda
>Cc: mysql@lists.mysql.com
>Subject: Re: improving random record selection
>
>On Sat, May 17, 2008 at 2:32 PM, Scott Haneda &l
>From: Scott Haneda [mailto:[EMAIL PROTECTED]
>Sent: Saturday, May 17, 2008 5:32 PM
>To: mysql@lists.mysql.com
>Subject: improving random record selection
>
>I posted this a month or so ago, and was helped a little, but I am now
>back.
>
>Currently I use select x, y, z f
On Sat, May 17, 2008 at 2:32 PM, Scott Haneda <[EMAIL PROTECTED]> wrote:
>$sql = "
>SELECT storage_path, image_md5, t.id
>FROM images AS t
>JOIN
>(SELECT CEIL(MAX(id)*RAND()) AS id FROM images) AS x
> ON (t.id >
I posted this a month or so ago, and was helped a little, but I am now
back.
Currently I use select x, y, z from images where (condition) order by
rand() limit 1;
As most know, it is slow, depending on the record set, and what I
compare it to, it can be from one order of magnitude slower,
> zv Green wrote:
>> Hello all,
>>
>> What I want to do is select all the records from the table but where
>> there
>> are duplicate entries (based on say, the surname and postcode fields)
>> pick a random record and then ignore the rest.
>
> If
zv Green wrote:
Hello all,
What I want to do is select all the records from the table but where
there
are duplicate entries (based on say, the surname and postcode fields)
pick a random record and then ignore the rest.
If you want to pick a random record, you can do ORDER BY RANDOM LIMIT 1
pick a random record and then ignore the rest. Lets say i have 2000
records in the table but 5 of them are dupes based on the surname and
postcode, how can I pick one of those 5 at random and return it with
the rest of the table.
Any help would be greatly appreciated.
--
MySQL General Mailing Lis
Michael Stassen wrote:
For example, if the selected random id is missing, we take the next id we
find, like this:
SELECT @rand_id:= CAST( 1 + MAX(id)*RAND() AS UNSIGNED) FROM history;
SELECT * FROM history WHERE id >= @rand_id LIMIT 1;
That will have a possibly undesired effect. Records that
Michael Stassen wrote:
For example, if the selected random id is
missing, we take the next id we find, like this:
SELECT @rand_id:= CAST( 1 + MAX(id)*RAND() AS UNSIGNED) FROM history;
SELECT * FROM history WHERE id >= @rand_id LIMIT 1;
That will have a possibly undesired effect. Records that
Eric Bergen wrote:
in() can take millions of arguments. Up to max packet size. Try it :)
True, but several past threads have suggested that performance drops
dramatically when the size of the IN list gets too large. As IN is
equivalent to an equality check for each value in the list, separated b
riginal Message - From: <[EMAIL PROTECTED]>
To: "Gary Huntress" <[EMAIL PROTECTED]>
Cc:
Sent: Sunday, May 15, 2005 6:42 AM
Subject: Re: Efficiently finding a random record
Hi,
i did the test and agree with you. even with
Select ID from history where id = 1+CAST( rand
tress" <[EMAIL PROTECTED]>
Cc:
Sent: Sunday, May 15, 2005 6:42 AM
Subject: Re: Efficiently finding a random record
Hi,
i did the test and agree with you. even with
Select ID from history where id = 1+CAST( rand() * 19 as UNSIGNED)
limit 1;
when testing : select CAST( rand() * 1
en" <[EMAIL PROTECTED]>
> To: "Dan Bolser" <[EMAIL PROTECTED]>
> Cc: "Philip Hallstrom" <[EMAIL PROTECTED]>; "Brian Dunning"
> <[EMAIL PROTECTED]>;
> Sent: Friday, May 13, 2005 7:48 PM
> Subject: Re: Efficiently findi
rom: "Eric Bergen" <[EMAIL PROTECTED]>
To: "Dan Bolser" <[EMAIL PROTECTED]>
Cc: "Philip Hallstrom" <[EMAIL PROTECTED]>; "Brian Dunning"
<[EMAIL PROTECTED]>;
Sent: Friday, May 13, 2005 7:48 PM
Subject: Re: Efficiently finding a random r
'in' limit. When you say 'thousands of numbers' do you
mean in the IN or in the column?
-Eric
Philip Hallstrom wrote:
I have a db of about 300,000 records and when I try to find one
random record like this:
select * from table order by rand() limit 1;
it can take sever
;thousands of numbers' do you
mean in the IN or in the column?
>
>-Eric
>
>
>Philip Hallstrom wrote:
>
>>> I have a db of about 300,000 records and when I try to find one
>>> random record like this:
>>>
>>> select * from table order by rand(
erate more random numbers
and try again.
in() is blazing fast even with thousands of numbers so don't be afraid
to kick a few extra in.
-Eric
Philip Hallstrom wrote:
I have a db of about 300,000 records and when I try to find one
random record like this:
select * from table order by rand() l
I have a db of about 300,000 records and when I try to find one random record
like this:
select * from table order by rand() limit 1;
it can take several minutes. My Sherlock Holmes instincts tell me that what
I'm doing is somehow inefficient. What is the primary culprit here?
The culpr
At 12:54 PM 5/13/05, Brian Dunning wrote:
I have a db of about 300,000 records and when I try to find one
random record like this:
select * from table order by rand() limit 1;
it can take several minutes. My Sherlock Holmes instincts tell me
that what I'm doing is somehow inefficient. What i
I have a db of about 300,000 records and when I try to find one
random record like this:
select * from table order by rand() limit 1;
it can take several minutes. My Sherlock Holmes instincts tell me
that what I'm doing is somehow inefficient. What is the primary
culprit here?
--
t;
To: "'Rhino'" <[EMAIL PROTECTED]>
Sent: Friday, January 14, 2005 11:43 AM
Subject: RE: Selecting a random record from more than 1 table
> Hi Rhino,
>
> Basically, that's exactly what I am trying to do. 2 tables with different
> designs and different
- Original Message -
From: "Christian Biggins" <[EMAIL PROTECTED]>
To:
Sent: Friday, January 14, 2005 12:07 AM
Subject: Selecting a random record from more than 1 table
> Hi Guys
>
> I am trying to display 1 random record taken from 2 tables.
>
> I have
Hi Guys
I am trying to display 1 random record taken from 2 tables.
I have tried the following;
SELECT table1.record1, table1.record2, table2.record1 FROM table1, table2
ORDER BY RAND() Limit 1
With no luck... So now I am trying to use CREATE VIEW but also with no
luck... Can anybody help out
mos wrote:
At 05:08 PM 5/22/2004, you wrote:
Robb Kerr wrote:
Got a simple table that contains records which are made up of only three
fields - ID, quote and author. These are "inspirational" quotes that
I want
to appear at the bottom of the pages of my website. I want them to
come up
randomly wi
At 05:08 PM 5/22/2004, you wrote:
Robb Kerr wrote:
Got a simple table that contains records which are made up of only three
fields - ID, quote and author. These are "inspirational" quotes that I want
to appear at the bottom of the pages of my website. I want them to come up
randomly with every page
Robb Kerr wrote:
Got a simple table that contains records which are made up of only three
fields - ID, quote and author. These are "inspirational" quotes that I want
to appear at the bottom of the pages of my website. I want them to come up
randomly with every page load. How do I randomly access re
How's that for alliteration in a subject line?
Got a simple table that contains records which are made up of only three
fields - ID, quote and author. These are "inspirational" quotes that I want
to appear at the bottom of the pages of my website. I want them to come up
randomly with every page lo
I just checked...
83
On Mon, 15 Sep 2003 13:54:53 +0100, "Andy Eastham"
<[EMAIL PROTECTED]> wrote:
| 39?
|
| > -Original Message-
| > From: tuncay bas [mailto:[EMAIL PROTECTED]
| > Sent: 15 September 2003 13:32
| > To: mysql
| > Subject: random record
pls unsubscribe me from this maillist. thanks.
- Original Message -
From: "Andy Eastham" <[EMAIL PROTECTED]>
To: "Mysql List" <[EMAIL PROTECTED]>
Sent: Monday, September 15, 2003 8:54 PM
Subject: {Scanned} RE: random record
> 39?
>
> > ---
39?
> -Original Message-
> From: tuncay bas [mailto:[EMAIL PROTECTED]
> Sent: 15 September 2003 13:32
> To: mysql
> Subject: random record
>
>
> hi,
>
> why its mysql database over random record use?
--
MySQL General Mailing List
For list archives: h
hi,
why its mysql database over random record use?
hi,
why its mysql database over random record use?
If you have a field 'weight', you could
SELECT *, RAND()*weight AS r FROM table_name ORDER BY r
(Or you can complicate the expression more :-)
laszlo
Ed Lazor wrote:
Ed Lazor wrote:
> I found this:
> SELECT * FROM table_name ORDER BY RAND()
>
> Is there a way to weight the random selection so
I found this:
SELECT * FROM table_name ORDER BY RAND()
Is there a way to weight the random selection so that certain records are
more likely to come up?
It's for a banner exchange program. The idea is to somehow give precedence
to help promote certain sites.
Thanks! =)
-Ed
You have to have version 3.23 of mysql and then you can add ORDER BY RAND()
to the end of your query.
Alan
-Original Message-
From: joe [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 25, 2018 4:40 PM
To: MySQL
Subject: Random record
Does anyone have any good ideas on how to pull a
Dear MySQL masters,
Is there any way to display a random record from a table. If there are no
direct SQL commands can you pls suggest a logic for doing the same.
Details:
There is a table of 200 records. The user must be able to select a record
randomly. Once that record is displayed then
.
ryan
- Original Message -
From: "joe" <[EMAIL PROTECTED]>
To: "MySQL" <[EMAIL PROTECTED]>
Sent: Sunday, February 25, 2018 5:39 PM
Subject: Random record
Does anyone have any good ideas on how to pull a random record? I've been
using PHP's rand
Check the archives. The answer you seek is there.
Cal
http://www.calevans.com
-Original Message-
From: joe [mailto:[EMAIL PROTECTED]]
Sent: Sunday, February 25, 2018 5:40 PM
To: MySQL
Subject: Random record
Does anyone have any good ideas on how to pull a random record? I've
Does anyone have any good ideas on how to pull a random record? I've been using PHP's
random function to create a random number to pull, but the problem is that if I delete
a record, it could still try to pull it. Is there a better way? I'd really like to
be able to just pul
Check the archives, we had this discussion a few weeks ago and someone came
up with a good solution.
Cal
http://www.calevans.com
-Original Message-
From: Sheni R. Meledath [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 24, 2001 9:05 AM
To: MySQL Masters
Subject: Random record from
Dear MySQL masters,
Can I select a random record from a table. After doing a query on a table
can i retrieve a record randomly. Is there a way in MySQL to achieve this.
If, can you please send me details.
thanks
Sheni R Meledath
[EMAIL PROTECTED
15:15
> To: [EMAIL PROTECTED]
> Subject: FW: Selecting a random record
>
>
> Any idea why I get this error when I try to create this table
> on a clean
> 3.23.30 install on a BSDI box.
> This was the output from a mysqldump from version 2.22.32 on a working
> datab
Any idea why I get this error when I try to create this table on a clean
3.23.30 install on a BSDI box.
This was the output from a mysqldump from version 2.22.32 on a working
database. It will not allow me to recreate my database on the new version.
mysql> CREATE TABLE pp_additional_features (
not working for us. I am trying to design a section of code in ASP
>to connect to the database and return a random record. Here is what I have
>so far:
>
> set SQL_Con = Server.CreateObject("ADODB.Connection")
> set SQL_Rec = Server.CreateObject(&quo
On the site Adoption.com we have been using a mysql database to set up
families who want to adopt. We have since redesigned our site and the old
code is not working for us. I am trying to design a section of code in ASP
to connect to the database and return a random record. Here is what I
47 matches
Mail list logo