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
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
distinct(dealer_web_na
Am 15.07.2011 19:40, schrieb Jan Steinman:
>> From: Reindl Harald
>>
>> 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 idi
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 *, NewI
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 wrote:
> This wo
r
On Fri, Jul 15, 2011 at 1:40 PM, Jan Steinman wrote:
> > From: Reindl Harald
> >
> > 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.
&g
> From: Reindl Harald
>
> 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
riginal Message -
From: "Jerry Schwartz"
To: "'Andre Matos'" ; "'Steven Staples'"
Cc:
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 [mailto
On Fri, May 28, 2010 at 11:38 AM, Andre Matos 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.
You'd be better off usin
drema...@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
>>
>-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,
>-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
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
>
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
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
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
g USING (aka
=) rather than >= . You were also doing a WHERE 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/
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
F
> 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
return an empty on occasion,
> 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, SE
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
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 t
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 with
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
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 c
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]
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 o
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
drop 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 displ
oduto p 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
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 `
[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]
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 t
[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: http:/
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: http://lists.m
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
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.spani
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 = &quo
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.pi
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.pi
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 i
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&qu
ples of (id_fruits, 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
>
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
get 100 random couples of (id_fruits, 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
FRO
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
edupe(
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,
> B) You want a list of 100 un-duplicated random rows from 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
> Unimi
m 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
> 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:
>
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:
>
> explanati
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
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:
t
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
BSTRING(MAX(CONCAT(TRUNCATE(RAND(),4),title)),7) AS Title
>FROM banners
>GROUP BY user_id;
Thank you so much. This solution works correctly.
--
Alessandro 'Asterix' Astarita <[EMAIL PROTECTED]>
CapriOnLine S.r.l. http://www.caprionline.com/
"Unix IS user
ion
<http://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),titl
-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] [mai
> 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 |
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:
>
&g
the banner
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]
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 is
ly want 30. That way, you can 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
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 Mess
only be used for
quick lookups in random selects anyway. Then, if record 6 is removed,
record 7 would 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
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
just do 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
> > when dealing with the meta-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 R
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. Splitti
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
[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) the
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 to
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 th
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 be
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
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-pa
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
> t
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 this
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
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 u
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
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
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"
>
&g
"Tue 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.
>
> Ex
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
Description:
The problem is affected in combination with 'order by' and
'rand()'.
Please check the report under:
http://bugs.php.net/bug.php?id=13287&edit=1
How-To-Repeat:
You can compare my results with the method which is reported i
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
ORD
[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 = &
> $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 e
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
[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(
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
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 f
L List [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:
> >
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
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 head, I'd guess that the reason for the slowdown has to
do
> with MySQL doing a new RAND() call for
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
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]]
Sen
x, but when I
>run 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
,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,
S
Quoted from the manual page I have given below is:
"RAND() is not meant to be a perfect random generator, but instead a fast
way to generate ad hoc random numbers that will be portable between
platforms for the same MySQL version."
So it was intentionally built so...
Gurhan
---
1 - 100 of 137 matches
Mail list logo