grouping and limiting results and rand()

2013-09-23 Thread Jeremiah Jester
Hello, How would i go about selecting 5 random cars that are flagged as internet_special (value 1) for each dealer from a specific table? Ive tried sub selects with no luck. Here's a basic query that has my required conditional. Note that I get all unique dealers by doing a

Re: grouping and limiting results and rand()

2013-09-23 Thread Peter Brawley
On 2013-09-23 8:10 PM, Jeremiah Jester wrote: Hello, How would i go about selecting 5 random cars that are flagged as internet_special (value 1) for each dealer from a specific table? Ive tried sub selects with no luck. Here's a basic query that has my required conditional. Note that I get all

MySQL RAND() Issues [was Re: How to Shuffle data]

2011-07-15 Thread Jan Steinman
From: Reindl Harald h.rei...@thelounge.net do not use any random-functions of mysql even if they exists http://bugs.mysql.com/bug.php?id=59253 Of course, it depends on the desired quality of randomness needed. I'm using RAND() to select random quotations to put at the end of emails. I can

Re: MySQL RAND() Issues [was Re: How to Shuffle data]

2011-07-15 Thread Arthur Fuller
RAND() to select random quotations to put at the end of emails. I can easily repeat the process by re-selecting the Signature: menu in Apple Mail. Problem is, I often notice that doing so cycles through several similar signatures in a decidedly non-random way! (You can demo this by sending

Re: MySQL RAND() Issues [was Re: How to Shuffle data]

2011-07-15 Thread Michael Dykman
I have found this approach pretty effective: select *, rand() r from [mytable] where [condition] order by r limit 10 as long as you are aware that a random number is generated for every row in the table. - michael dykman On Fri, Jul 15, 2011 at 2:12 PM, Arthur Fuller fuller.art

Re: MySQL RAND() Issues [was Re: How to Shuffle data]

2011-07-15 Thread Dan Nelson
In the last episode (Jul 15), Arthur Fuller said: This would be sooo much simpler to solve in MS-SQL, given the function NewID(), which is guaranteed to return a unique value. I have used this in a few web sites and it works splendidly; something along the lines of SELECT TOP 10 *, NewID()

Re: MySQL RAND() Issues [was Re: How to Shuffle data]

2011-07-15 Thread Reindl Harald
Am 15.07.2011 19:40, schrieb Jan Steinman: From: Reindl Harald h.rei...@thelounge.net do not use any random-functions of mysql even if they exists http://bugs.mysql.com/bug.php?id=59253 So RAND() can be useful, but it is not really very random the problem is the idiotic temp table fecth

Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Andre Matos
Hi All, I have a table that uses auto_increment to generate the Id automatically working fine. However, I need to create a new table where the Id must be a number generated randomly, so I cannot use the auto_increment. MySQL has a function RAND. So I could use something like this: SELECT

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jim Lyons
the auto_increment. MySQL has a function RAND. So I could use something like this: SELECT FLOOR(RAND() * COUNT(*)) AS RandId FROM mytable But, let's suppose that the RandId is a number that was already used in the table. Then I need to run the SELECT again and again until I find a number that hasn't

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Steven Staples
If you wanted to use/go that route, then why not select a random limit 1 from that table, and then delete that row? SELECT `column` FROM `table` ORDER BY RAND() LIMIT 1; On a side note, I would use the auto-inc field still, and store this number in another field. Steven Staples

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Andre Matos
not select a random limit 1 from that table, and then delete that row? SELECT `column` FROM `table` ORDER BY RAND() LIMIT 1; On a side note, I would use the auto-inc field still, and store this number in another field. Steven Staples -Original Message- From: Jim Lyons

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jerry Schwartz
-Original Message- From: Jim Lyons [mailto:jlyons4...@gmail.com] Sent: Friday, May 28, 2010 11:49 AM To: Andre Matos Cc: mysql@lists.mysql.com Subject: Re: Using RAND to get a unique ID that has not been used yet If your specs are that specific (IDs must be between 1 and 99) then you

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jerry Schwartz
-Original Message- From: Andre Matos [mailto:andrema...@mineirinho.org] Sent: Friday, May 28, 2010 1:44 PM To: Steven Staples Cc: mysql@lists.mysql.com Subject: Re: Using RAND to get a unique ID that has not been used yet It seems to be a good approach, although I was trying to get

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Andre Matos
...@mineirinho.org On 2010-05-28, at 1:51 PM, Jerry Schwartz wrote: -Original Message- From: Andre Matos [mailto:andrema...@mineirinho.org] Sent: Friday, May 28, 2010 1:44 PM To: Steven Staples Cc: mysql@lists.mysql.com Subject: Re: Using RAND to get a unique ID that has

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Perrin Harkins
On Fri, May 28, 2010 at 11:38 AM, Andre Matos andrema...@mineirinho.org wrote: I have a table that uses auto_increment to generate the Id automatically working fine. However, I need to create a new table where the Id must be a number generated randomly, so I cannot use the auto_increment.

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Kevin (Gmail)
- From: Jerry Schwartz je...@gii.co.jp To: 'Andre Matos' andrema...@mineirinho.org; 'Steven Staples' sstap...@mnsi.net Cc: mysql@lists.mysql.com Sent: Friday, May 28, 2010 6:51 PM Subject: RE: Using RAND to get a unique ID that has not been used yet -Original Message- From: Andre Matos

Re: Age old order by rand() issue

2008-05-02 Thread Scott Haneda
I have seen nicer fast random row implement, but that will work. Do you happen to have a snip of it, the one I have seems to lean pretty heavy as far as I can tell, and on occasion, though rare, also sends me an empty result set. -- Scott [EMAIL PROTECTED] -- MySQL General Mailing List

Re: Age old order by rand() issue

2008-05-02 Thread Rob Wultsch
clause on that could have removed the random result. My only problem with what you are using is that it is more likely to give a large results than a small one. Take a look at the http://jan.kneschke.de/projects/mysql/order-by-rand/ You probably do not need this. If you have a large data set, you

Age old order by rand() issue

2008-05-01 Thread Scott Haneda
List search seems to return 0 results, and I am a bit stumped. Getting a more optimized order by random with 1 record... I found a snip online that works, but seems to return an empty on occasion, and I am not sure why: SELECT storage_path, image_md5, id FROM images JOIN (SELECT CEIL(RAND

Re: Age old order by rand() issue

2008-05-01 Thread Rob Wultsch
, and I am not sure why: SELECT storage_path, image_md5, id FROM images JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM images WHERE approved = 1)) AS id) AS r2 USING (id) WHERE approved = 1; I really do not get this, SELECT CEIL(RAND() will always return 1 will it not? Any idea

Re: Age old order by rand() issue

2008-05-01 Thread Rob Wultsch
SELECT storage_path, image_md5, id FROM images JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM images WHERE approved = 1)) AS id) AS r2 USING (id) WHERE approved = 1; I really do not get this, SELECT CEIL(RAND() will always return 1 will it not? Any idea why I get an empty result

implementation of SELECT ... ORDER BY RAND() LIMIT 1

2007-02-08 Thread Jan Pieter Kunst
2007/2/7, Jos Elkink [EMAIL PROTECTED]: Hi all, I have a question about the combination of RAND and LIMIT 1. If I have a query like: SELECT ... ORDER BY RAND() LIMIT 1 with the ... replaced with a normal query on one table. How is this implemented? Is this optimized for the fact that it only

implementation of SELECT ... ORDER BY RAND() LIMIT 1

2007-02-07 Thread Jos Elkink
Hi all, I have a question about the combination of RAND and LIMIT 1. If I have a query like: SELECT ... ORDER BY RAND() LIMIT 1 with the ... replaced with a normal query on one table. How is this implemented? Is this optimized for the fact that it only needs one entry? And what about when

Re: implementation of SELECT ... ORDER BY RAND() LIMIT 1

2007-02-07 Thread Philip Hallstrom
I have a question about the combination of RAND and LIMIT 1. If I have a query like: SELECT ... ORDER BY RAND() LIMIT 1 with the ... replaced with a normal query on one table. How is this implemented? Is this optimized for the fact that it only needs one entry? Try prefixing your query

Re: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-10 Thread uYe
Add DISTINCT(primary_key) in your query? Regards Willy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

RE: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-10 Thread Jerry Schwartz
The SELECT that Daevid originally tried is straight out of the documentation, which says that ORDER BY RAND() LIMIT x is a good way to get a random sample of your data. The documentation also says you can't use a RAND() column in an ORDER BY clause because the ORDER BY would evaluate the column

ORDER BY RAND() gives me duplicate rows sometimes

2006-11-09 Thread Daevid Vincent
I am using this query to pull three random comments from a table: SELECT *, DATE_FORMAT(created_on, '%b %D') as date_format FROM comments ORDER BY RAND() LIMIT 3; The problem is that sometimes, I get two of the same comment. How can I refine this query to give me 3 unique/distinct ones

Re: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-09 Thread Christian Hammers
On 2006-11-09 Daevid Vincent wrote: I am using this query to pull three random comments from a table: SELECT *, DATE_FORMAT(created_on, '%b %D') as date_format FROM comments ORDER BY RAND() LIMIT 3; The problem is that sometimes, I get two of the same comment. How can I refine

rand()

2006-07-07 Thread Jo�o C�ndido de Souza Neto
Hi everyone, I´ve got a page where a ought to get 20 registers in ramdom order but i want to display it in an alphabetical order. Someone knows if there is a way to get that 20 random registers in alphabetical order? Thanks. -- MySQL General Mailing List For list archives:

RE: rand()

2006-07-07 Thread Jay Blanchard
[snip] I´ve got a page where a ought to get 20 registers in ramdom order but i want to display it in an alphabetical order. Someone knows if there is a way to get that 20 random registers in alphabetical order? [/snip] SORT BY `registers` -- MySQL General Mailing List For list archives:

Re: rand()

2006-07-07 Thread Jo�o C�ndido de Souza Neto
Excuse me, but i don´t understand your answer. Could you explain it? Jay Blanchard [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] [snip] I´ve got a page where a ought to get 20 registers in ramdom order but i want to display it in an alphabetical order. Someone knows if there is

RE: rand()

2006-07-07 Thread Jay Blanchard
[snip] Excuse me, but i don´t understand your answer. Could you explain it? [/snip] Add it to the end of your query -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: rand()

2006-07-07 Thread Eugene Kosov
I think you meant ORDER BY `registers`.. Jay Blanchard пишет: [snip] I´ve got a page where a ought to get 20 registers in ramdom order but i want to display it in an alphabetical order. Someone knows if there is a way to get that 20 random registers in alphabetical order? [/snip] SORT BY

Re: rand()

2006-07-07 Thread Jo�o C�ndido de Souza Neto
on g.produto_id=p.id where (select count(*) from produtos_lista pl where pl.grade_id=g.grade_id)=0 order by rand() limit 20) as t1 order by t1.nome Thanks again. João Cândido de Souza Neto [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi everyone, I´ve got a page where a ought to get 20

Re: rand()

2006-07-07 Thread mos
temporary table if exists tmpreg; create temporary table tmpreg select registers from tablex order by rand() limit 10; select * from temporary tmpreg order by registers; Mike Jay Blanchard пишет: [snip] I´ve got a page where a ought to get 20 registers in ramdom order but i want to display

Making ORDER BY RAND() more random [resend]

2005-10-03 Thread Graham Anderson
is there a way to make ORDER BY RAND() at bit more spontaneous ? I am using it in a php statement: $sql = SELECT media.id, artist.name as artist, artist.spanish as bio, artist.purchaseLink, artist.picture

Re: Making ORDER BY RAND() more random [resend]

2005-10-03 Thread Henry Wong
change the seed on the random function. http://dev.mysql.com/doc/mysql/en/mathematical-functions.html On Mon, 2005-10-03 at 08:33 -0700, Graham Anderson wrote: is there a way to make ORDER BY RAND() at bit more spontaneous ? I am using it in a php statement: $sql = SELECT media.id

Re: Making ORDER BY RAND() more random [resend]

2005-10-03 Thread Michael Stassen
Graham Anderson wrote: is there a way to make ORDER BY RAND() a bit more spontaneous ? I am using it in a php statement: $sql = SELECT media.id, artist.name as artist, artist.spanish as bio, artist.purchaseLink, artist.picture, media.spanish as trackName

Re: Making ORDER BY RAND() more random [resend]

2005-10-03 Thread Graham Anderson
In the below query, the results first row is usually the same 3-4 tracks out of 30. so should I use PHP to generate a random seed, $r, and pass that to the query ? ORDER BY RAND($r) or, can it be done just with mysql many thanks g On Oct 3, 2005, at 10:15 AM, Michael Stassen wrote: Graham

Making ORDER BY RAND() more random

2005-09-30 Thread Graham Anderson
is there a way to make ORDER BY RAND() at bit more spontaneous ? I am using it in a php statement: $sql = SELECT media.id, artist.name as artist, artist.spanish as bio, artist.purchaseLink, artist.picture

Re: ORDER BY rand()

2004-08-20 Thread Philippe Poelvoorde
Craig Hoffman wrote: Hey Folks, I have a query where it pulls random data and display's it. SELECT route_photo, route, route_count, area FROM routes WHERE ORDER BY RAND() LIMIT 1 The query works fine, however, the route_photo field is partially populated. This results in just a route name

ORDER BY rand()

2004-08-19 Thread Craig Hoffman
Hey Folks, I have a query where it pulls random data and display's it. SELECT route_photo, route, route_count, area FROM routes WHERE ORDER BY RAND() LIMIT 1 The query works fine, however, the route_photo field is partially populated. This results in just a route name appearing

Re: join subquerie rand problem

2004-07-21 Thread Gerske, Sebastian
id_fruits AS my_id_fruits, (SELECT id_animals FROM fruits_animals WHERE id_fruits = my_id_fruits ORDER BY RAND() LIMIT 1) AS my_id_animals FROM fruits_animals GROUP BY my_id_fruits ORDER BY RAND() LIMIT 100; You have your unique many-to-many relations' table, you just have to join

join subquerie rand problem

2004-07-20 Thread Gerske, Sebastian
Hello list, i still need a solution for my 3 table join rand problem, im using version 4.1 now so subqueries are possible: explanation: i have 3 tables lets say: fruits: id, name 1banana 2apple 3strawberry fruits_animals id, id_fruits, id_animals 11 2 2

Re: join subquerie rand problem

2004-07-20 Thread Gerske, Sebastian
help me please :/ Gerske, Sebastian [EMAIL PROTECTED] schrieb im Newsbeitrag news:[EMAIL PROTECTED] Hello list, i still need a solution for my 3 table join rand problem, im using version 4.1 now so subqueries are possible: explanation: i have 3 tables lets say: fruits: id, name 1

Re: join subquerie rand problem

2004-07-20 Thread Gerske, Sebastian
rand problem, im using version 4.1 now so subqueries are possible: explanation: i have 3 tables lets say: fruits: id, name 1banana 2apple 3strawberry fruits_animals id, id_fruits, id_animals 11 2 21 3 33

Re: join subquerie rand problem

2004-07-20 Thread SGreen
the relationship table? - OR - C) Each time you run your query containing ORDER BY RAND() , you get the exact same set of records back? Yours, Shawn Green Database Administrator Unimin Corporation - Spruce Pine Gerske, Sebastian [EMAIL PROTECTED] wrote on 07/20/2004 06:18:11 AM: help me please

Re: join subquerie rand problem

2004-07-20 Thread Gerske, Sebastian
the relationship table? - OR - C) Each time you run your query containing ORDER BY RAND() , you get the exact same set of records back? Yours, Shawn Green Database Administrator Unimin Corporation - Spruce Pine Gerske, Sebastian [EMAIL PROTECTED] wrote on 07/20/2004 06:18:11 AM: help me please

Re: join subquerie rand problem

2004-07-20 Thread SGreen
( animal_id int not null, fruit_id int not null, UNIQUE INDEX (animal_id), UNIQUE INDEX (fruit_id) ) INSERT IGNORE tmpDedupe (animal_id, fruit_id) SELECT (id_fruits, id_animals) FROM fruits_animals SELECT * FROM tmpDedupe ORDER BY RAND() LIMIT 100 DROP TABLE tmpDedupe Make sense? Yours, Shawn

Re: join subquerie rand problem

2004-07-20 Thread Gerske, Sebastian
brings the same result as select * from fruit, fruit_animal, animal where fruit.id = fruit_animal.id_fruit AND fruit_animal.id_animal = animal.id order by rand() or i got something wrong the next thing is that the tables are hughe, like 3 millionen rows (growing) thanks

Re: join subquerie rand problem

2004-07-20 Thread Arnaud
, id_animals), with unique id_fruits and unique id_animals, right ? SELECT id_fruits AS my_id_fruits, (SELECT id_animals FROM fruits_animals WHERE id_fruits = my_id_fruits ORDER BY RAND() LIMIT 1) AS my_id_animals FROM fruits_animals GROUP BY my_id_fruits

Re: join subquerie rand problem

2004-07-20 Thread Arnaud
ORDER BY RAND() LIMIT 1) AS my_id_animals FROM fruits_animals GROUP BY my_id_fruits) AS tmpQuery GROUP BY tmpQuery.my_id_animals ORDER BY whatever you want LIMIT 100; On 20 Jul 2004 at 16:36, Arnaud [EMAIL PROTECTED] wrote: i have lets say 1000 different fruits and 1000 different

Repost: Order by RAND + join problem

2004-06-01 Thread Gerske, Sebastian
Hello list, im having a hughe problem with the RAND() function first of all im using mysql 3.23 so subquerys are impossible. Im having three tables which are joined by ID's now i want to select a single row random out of the join set whats the best way to do it? My Table structure is: table1

Oder by RAND Problem

2004-05-24 Thread Gerske, Sebastian
Hello list, im having a hughe problem with the RAND() function first of all im using mysql 3.23 so subquerys are impossible. table1 --- | id | content | | 1 | apple | --- relation_table | id | id_table1 | id_table2 | | 1 | 1

Re: group by order by rand() problem

2004-04-02 Thread Alessandro Astarita
Alle 21:57, giovedì 1 aprile 2004, Michael Stassen ha scritto: You could probably accomplish this with a variant of the MAX-CONCAT trick http://www.mysql.com/doc/en/example-Maximum-column-group-row.html. Something like: SELECT user_id, SUBSTRING(MAX(CONCAT(TRUNCATE(RAND(),4

Re: group by order by rand() problem

2004-04-01 Thread Michael Stassen
://www.mysql.com/doc/en/GROUP-BY-hidden-fields.html. You could probably accomplish this with a variant of the MAX-CONCAT trick http://www.mysql.com/doc/en/example-Maximum-column-group-row.html. Something like: SELECT user_id, SUBSTRING(MAX(CONCAT(TRUNCATE(RAND(),4),title)),7) AS Title FROM

group by order by rand() problem

2004-03-31 Thread [EMAIL PROTECTED]
doesn't change while multiple calls: SELECT * FROM banners GROUP BY user_id ORDER BY RAND(); Can anyone help me? Thanks in advance, Alex -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

RE: group by order by rand() problem

2004-03-31 Thread Dathan Vance Pattishall
Try seeding your rand. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 31, 2004 12:57 PM To: [EMAIL PROTECTED] Subject: group by order by rand() problem I have this table: mysql select * from banners

RE: group by order by rand() problem

2004-03-31 Thread [EMAIL PROTECTED]
Try seeding your rand. Tried. It doesn't work. The select shows always the same records but in different order: SELECT * FROM banners GROUP BY user_id ORDER BY RAND(); first call ++-+---+ | id | user_id | title | ++-+---+ | 1 | 1

RE: group by order by rand() problem

2004-03-31 Thread m.pheasant
-Original Message- From: Dathan Vance Pattishall [mailto:[EMAIL PROTECTED] Sent: Thursday, April 01, 2004 7:16 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: group by order by rand() problem Try seeding your rand. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL

ORDER BY RAND() performance

2004-03-08 Thread Neil Gunton
Hi all, I am using MySQL 4.0.x to run a community website which has (among other things) over 19,000 pictures. There is a page that selects 30 random thumbnails. I have noticed that the performance of ORDER BY RAND() on this table has a significant impact on performace. I have all the relevant

Re: ORDER BY RAND() performance

2004-03-08 Thread colbey
If your infact (sounds like) storing the pictures meta-data (name, size, owner, etc) and the data (blob of some kind) .. I would definately break up the design into 2 tables. That way when dealing with the meta-data table (your RAND() query) there is much less data that needs to be traversed

Re: ORDER BY RAND() performance

2004-03-08 Thread Neil Gunton
[EMAIL PROTECTED] wrote: If your infact (sounds like) storing the pictures meta-data (name, size, owner, etc) and the data (blob of some kind) .. I would definately break up the design into 2 tables. That way when dealing with the meta-data table (your RAND() query) there is much less data

RE: ORDER BY RAND() performance

2004-03-08 Thread Donny Simonton
ORDER BY RAND(), just sucks in my opinion. We have created our own internal randomization system because pretty much everytime you use it will show up in the slow query log, because of the using temporary, using filesort it does. Splitting your data into a hundred tables will still make it using

RE: ORDER BY RAND() performance

2004-03-08 Thread colbey
... On Mon, 8 Mar 2004, Donny Simonton wrote: ORDER BY RAND(), just sucks in my opinion. We have created our own internal randomization system because pretty much everytime you use it will show up in the slow query log, because of the using temporary, using filesort it does. Splitting your data

Re: ORDER BY RAND() performance

2004-03-08 Thread Ray
-data table (your RAND() query) there is much less data that needs to be traversed to get your answer, which should result in a faster query. Thanks! This is definitely good advice, but unfortunately it doesn't solve the RAND() slowness. I have been testing with a separate table that ONLY

RE: ORDER BY RAND() performance

2004-03-08 Thread Donny Simonton
a limit 19345, 1 or something like that. We have tried another option which we stopped using which was creating 30 random numbers and then doing 30 select statements. But that was slower overall than 1 select with order by rand. One other option that we use sometimes is say you need 30 results

Re: ORDER BY RAND() performance

2004-03-08 Thread Neil Gunton
Ray wrote: an alternative to the order by rand() with large record sets is to pick a random starting point limit $randPoint, 30 don't know if its a viable solution to your situation, but it limits you to 2 querys (row count, fetch) rather then the 30 (fetch 1 x 30) Thanks! I did see

Re: ORDER BY RAND() performance

2004-03-08 Thread Neil Gunton
become record 6, record 8 would now be 7 and so on. I know you can maintain this sort of thing yourself, but it takes work to maintain consistency and it would be a nice feature to have. If this was available then ORDER BY RAND() optimization would be easy, since you could have the sequence field

RE: ORDER BY RAND() performance

2004-03-08 Thread Donny Simonton
is not available. There are many options, we have even in some cases, created a table and run the order by rand query every 5 minutes and just have it update a table. And then we just do a select from that secondary table. So every 5 minutes you have new random items. Donny -Original Message

Re: ORDER BY RAND() performance

2004-03-08 Thread Neil Gunton
have extras, if say #20 is not available. There are many options, we have even in some cases, created a table and run the order by rand query every 5 minutes and just have it update a table. And then we just do a select from that secondary table. So every 5 minutes you have new random items

Re: ORDER BY RAND() performance

2004-03-08 Thread Sasha Pachev
extras, if say #20 is not available. There are many options, we have even in some cases, created a table and run the order by rand query every 5 minutes and just have it update a table. And then we just do a select from that secondary table. So every 5 minutes you have new random items. Another way

RAND ()

2003-11-04 Thread Payne
Hi, I have been playing around with RAND(). It works very well if I do a sql statement with mysql, but I having problem using with mysql statement with php. When a person calls on the page, the same output is always view. How can I get RAND() work with php. sorry for the php, stuff. Thanks

Re: RAND ()

2003-11-04 Thread Matt W
Hi Payne, This is probably because of a bug in MySQL versions before 3.23.56 and 4.0.10 -- RAND() didn't work right the first time it was used in a *new* connection. After the first run, though, it was OK. To work around the problem, I've told people to just call RAND() a few times before doing

order by rand()

2003-08-11 Thread H Marc Bower
Hey all... I did a quick check of the archives, but didn't see anything recent about this... I use PHP and mySQL, and am supposed to be able to randomize the order in which the rows are held when retrieved using ORDER BY RAND(). This isn't working for me... it's on a third-party server over

Problem With RAND()

2003-07-07 Thread Scott A. Hammond, Sr.
I am running MySQL 3.23.54. Query: SELECT column1, column2, RAND() AS column3 FROM table WHERE column2 IS NOT NULL ORDER BY column3 LIMIT 10; I am running this query within a PHP page that uses mysql_connect. More then 9 out of 10 times I get the first 10 rows of the database in order, i.e. 1

Re: Problem With RAND()

2003-07-07 Thread gerald_clark
Since you are ordering by column3, ( in other words sorting your random mumbers ), what do you expect? Scott A. Hammond, Sr. wrote: I am running MySQL 3.23.54. Query: SELECT column1, column2, RAND() AS column3 FROM table WHERE column2 IS NOT NULL ORDER BY column3 LIMIT 10; I am running

Re: Problem With RAND()

2003-07-07 Thread Sergei Golubchik
Hi! On Jul 07, Scott A. Hammond, Sr. wrote: I am running MySQL 3.23.54. Query: SELECT column1, column2, RAND() AS column3 FROM table WHERE column2 IS NOT NULL ORDER BY column3 LIMIT 10; I am running this query within a PHP page that uses mysql_connect. More then 9 out of 10 times I get

RAND() isn't :)

2003-02-27 Thread Justin French
Hi all, On my LAN server (FreeBSD, MySQL 3.32) the following query works fine, and seems to return 2 random rows from the table: SELECT * FROM disc ORDER BY RAND() LIMIT 2 However, when I upload the scripts to the live server (Linux, MySQL 3.32), the results are VERY un-random -- only very

Re: RAND() isn't :)

2003-02-27 Thread Zak Greant
On Fri, Feb 28, 2003 at 05:19:15PM +1100, Justin French wrote: Hi all, On my LAN server (FreeBSD, MySQL 3.32) the following query works fine, and seems to return 2 random rows from the table: SELECT * FROM disc ORDER BY RAND() LIMIT 2 However, when I upload the scripts to the live

Re: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux)

2003-02-11 Thread Sergei Golubchik
Hi! On Feb 05, Tue Tønning wrote: Hey, I have discovered a strange error in the mysql versions mentioned in subj. Example. A table with 10 entries ...i want to draw 3 randomly = select fieldName from tableName order by RAND() limit 3 this have worked for the last year or so

RE: RAND is mysql 3.22

2003-02-11 Thread Daniel Rossi
hi guys i just tried this on my works old mysql server and it doesnt seem to work , is it possible ? :| - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the

Re: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux)

2003-02-08 Thread Aman Raheja
Tønning [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, February 05, 2003 1:38 PM Subject: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux) Hey, I have discovered a strange error in the mysql versions mentioned in subj. Example. A table with 10 entries ...i want to draw 3

RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux)

2003-02-06 Thread Tue Tønning
Hey, I have discovered a strange error in the mysql versions mentioned in subj. Example. A table with 10 entries ...i want to draw 3 randomly = select fieldName from tableName order by RAND() limit 3 this have worked for the last year or so.but after upgrading our redhat 7.2 with mysql

random order with rand() is foreseeing

2002-07-24 Thread Steve Alberty
Description: The problem is affected in combination with 'order by' and 'rand()'. Please check the report under: http://bugs.php.net/bug.php?id=13287edit=1 How-To-Repeat: You can compare my results with the method which is reported in php bug report number

Re: ORDER BY RAND() not working

2002-07-12 Thread Arthur Fuller
I don't have your exact setup installed so cannot verify this, but how about rewriting your statement a little? I just tried this in mysql and it works fine, so it may from php. Let me know :-) Change the query to: SELECT *, Rand() as MyOrder FROM products WHERE sale_price IS NOT NULL ORDER

ORDER BY RAND() not working

2002-07-11 Thread Jamie Tibbetts
I'm running PHP 4.1.2 and MySQL 3.23.39. I have a simple query that works if I telnet into MySQL and run the query manually. If I try and use it in a PHP page, I get the Supplied argument is not a valid MySQL result resource error. However, if I take out the ORDER BY RAND() part from the query

RE: ORDER BY RAND() not working

2002-07-11 Thread Jay Blanchard
[snip] I'm running PHP 4.1.2 and MySQL 3.23.39. I have a simple query that works if I telnet into MySQL and run the query manually. If I try and use it in a PHP page, I get the Supplied argument is not a valid MySQL result resource error. However, if I take out the ORDER BY RAND() part from

RE: ORDER BY RAND() not working

2002-07-11 Thread Alain Fontaine
What does your PHP code look like ? It might be a syntax problem inside PHP -Message d'origine- De : Jamie Tibbetts [mailto:[EMAIL PROTECTED]] Envoye : jeudi 11 juillet 2002 18:22 A : [EMAIL PROTECTED] Objet : ORDER BY RAND() not working I'm running PHP 4.1.2 and MySQL 3.23.39. I

Re: ORDER BY RAND() not working

2002-07-11 Thread Jamie Tibbetts
$id = mysql_query(SELECT * FROM products WHERE sale_price IS NOT NULL ORDER BY RAND() LIMIT 3,$link) or die(mysql_error()); PHP code: $result = mysql_query(SELECT * FROM products WHERE sale_price IS NOT NULL ORDER BY RAND() LIMIT 3) or die(mysql_error()); The error message is as follows: You

RE: ORDER BY RAND() not working

2002-07-11 Thread Jay Blanchard
[snip] PHP code: $result = mysql_query(SELECT * FROM products WHERE sale_price IS NOT NULL ORDER BY RAND() LIMIT 3) or die(mysql_error()); The error message is as follows: You have an error in your SQL syntax near 'RAND() LIMIT 3' at line 1 [/snip] Using; $query = select * from tblBAR WHERE

rand() ... limit by .... my retrivals

2002-07-09 Thread toby -
hi guys im trying to retrieve 5 record each page from my db my code iz : $query_nme = SELECT firstName, lastName, title, summary FROM ctnt_inf where ctnt_id ORDER BY RAND() LIMIT 5; $query_result_handle_nme = mysql_query ($query_nme) or die ('qry failed ! DA tbl

Rand slowness.

2002-06-27 Thread MySQL List
Hi, Is there a quicker way to get a selection of random rows than RAND()? I basically use: SELECT * FROM table ORDER BY RAND() LIMIT 3; But I find that as the # of rows increases in table, it keeps taking longer and longer to get a result back. And I am talking a large increase, basically 50

RAND slowness?

2002-06-27 Thread MySQL List
Hi, Can someone tell me which query would be faster with say 1000 rows: SELECT * FROM table ORDER BY RAND() LIMIT 3; or SELECT * FROM table; then use php to get 3 random rows from the returned data? - Before posting, please

RE: Rand slowness.

2002-06-27 Thread Jon Frisby
[mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 2:44 PM To: Jon Frisby Cc: mysql Subject: Re: Rand slowness. I tried this, but it seems to be ignoring the LIMIT 3, since it is returning all the rows. Try: SELECT RAND() AS r, * FROM table ORDER BY r LIMIT 3; Off the top of my

RAND and MySQL version!

2002-05-14 Thread Soheil Shaghaghi
,IsActive FROM DATABASE WHERE IsActive=1 ORDER BY RAND() LIMIT 1 Can anyone please tell me if it's the version of MySQL causing this problem or something else? Is there anyway to get around this, without upgrading MySQL? Thanks so much, Soheil

Re: RAND and MySQL version!

2002-05-14 Thread Paul DuBois
it on the other server, I get sql error. SELECT ID,Headlines,IsActive FROM DATABASE WHERE IsActive=1 ORDER BY RAND() LIMIT 1 Can anyone please tell me if it's the version of MySQL causing this problem or something else? Yes. Expressions in the ORDER BY clause are not supported prior to 3.23.2

RE: RAND and MySQL version!

2002-05-14 Thread Gurhan Ozen
You can't do ORDER BY RAND() prior to version 3.23... On your 3.22.32 version do something like: SELECT column_name*0+RAND() AS rnd FROM table_name WHERE IsActive=1 ORDER BY rnd LIMIT 1; Gurhan -Original Message- From: Soheil Shaghaghi [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 14

Using RAND()

2002-05-07 Thread Cummings, Shawn (GNAPs)
The RAND() syntax does not appear to be working for me. What version mySQL is required? At 04:43 PM 1/29/2002 +0200, Michael Widenius wrote: Hi! Ulf == Ulf Harnhammar [EMAIL PROTECTED] writes: Ulf On Sun, 27 Jan 2002, Michael Widenius wrote: One way to do this is to do as follows

RE: Using RAND()

2002-05-07 Thread Gurhan Ozen
: Using RAND() The RAND() syntax does not appear to be working for me. What version mySQL is required? At 04:43 PM 1/29/2002 +0200, Michael Widenius wrote: Hi! Ulf == Ulf Harnhammar [EMAIL PROTECTED] writes: Ulf On Sun, 27 Jan 2002, Michael Widenius wrote: One way to do this is to do

  1   2   >