RE: improving random record selection

2008-05-19 Thread Jerry Schwartz
>-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

Re: improving random record selection

2008-05-19 Thread Rob Wultsch
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

RE: improving random record selection

2008-05-19 Thread Jerry Schwartz
>-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

RE: improving random record selection

2008-05-19 Thread Jerry Schwartz
>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

Re: improving random record selection

2008-05-17 Thread Rob Wultsch
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 >

improving random record selection

2008-05-17 Thread Scott Haneda
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,

Re: Choose a random record from a list of duplicates

2007-01-09 Thread Scott Haneda
> 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

Re: Choose a random record from a list of duplicates

2007-01-09 Thread Chris White
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

Choose a random record from a list of duplicates

2007-01-09 Thread Trev Green
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

Re: Efficiently finding a random record

2005-05-16 Thread Philip Hallstrom
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

Re: Efficiently finding a random record

2005-05-16 Thread Keith Ivey
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

Re: Efficiently finding a random record

2005-05-15 Thread Michael Stassen
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

Re: Efficiently finding a random record

2005-05-15 Thread Michael Stassen
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

Re: Efficiently finding a random record

2005-05-15 Thread Gary Huntress
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

Re: Efficiently finding a random record

2005-05-15 Thread mfatene
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

Re: Efficiently finding a random record

2005-05-14 Thread Gary Huntress
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

Re: Efficiently finding a random record

2005-05-13 Thread Eric Bergen
'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

Re: Efficiently finding a random record

2005-05-13 Thread Dan Bolser
;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(

Re: Efficiently finding a random record

2005-05-13 Thread Eric Bergen
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

Re: Efficiently finding a random record

2005-05-13 Thread Philip Hallstrom
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

Re: Efficiently finding a random record

2005-05-13 Thread Frank Bax
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

Efficiently finding a random record

2005-05-13 Thread Brian Dunning
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? --

Re: Selecting a random record from more than 1 table

2005-01-14 Thread Rhino
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

Re: Selecting a random record from more than 1 table

2005-01-14 Thread Rhino
- 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

Selecting a random record from more than 1 table

2005-01-13 Thread Christian Biggins
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

Re: Random Record Retrieval

2004-05-22 Thread Michael Stassen
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

Re: Random Record Retrieval

2004-05-22 Thread mos
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

Re: Random Record Retrieval

2004-05-22 Thread Hassan Schroeder
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

Random Record Retrieval

2004-05-22 Thread Robb Kerr
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

Re: random record

2003-09-15 Thread Michael Brunson
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

Re: {Scanned} RE: random record

2003-09-15 Thread Henry Wong
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? > > > ---

RE: random record

2003-09-15 Thread Andy Eastham
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

random record

2003-09-15 Thread tuncay bas
hi, why its mysql database over random record use?

random record

2003-09-15 Thread tuncay bas
hi, why its mysql database over random record use?

Re: weighted random record select?

2002-01-25 Thread laszlo
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

weighted random record select?

2002-01-25 Thread Ed Lazor
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

RE: Random record

2001-02-26 Thread Alan Halls
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

Select a Random record

2001-02-26 Thread Sheni R. Meledath
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

Re: Random record

2001-02-25 Thread ryc
. 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

RE: Random record

2001-02-25 Thread Cal Evans
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

Random record

2001-02-25 Thread joe
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

RE: Random record from a table

2001-02-24 Thread Cal Evans
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

Random record from a table

2001-02-24 Thread Sheni R. Meledath
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

RE: Selecting a random record

2001-01-15 Thread The Tilghman
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

FW: Selecting a random record

2001-01-15 Thread Alan Halls
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 (

Re: Selecting a random record

2001-01-15 Thread Scott Baker
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

Selecting a random record

2001-01-15 Thread Alan Halls
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