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
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
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
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
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
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()
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
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
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
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
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
-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
-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
...@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
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.
-
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
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
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
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
,
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
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
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
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
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
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]
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
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
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
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:
[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:
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
[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]
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
(
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
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
, 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
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
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
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
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
://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
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]
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
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
-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
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
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
[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
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
...
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
-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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
[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
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
$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
[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
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
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
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
[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
,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
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
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
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
: 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 - 100 of 129 matches
Mail list logo