Only table field names are allowed after the ORDER BY clause in standard SQL. The answer to your question is that SQL is not designed to do that kind of thing. Rather, I would suggest computing a random permutation of the numbers 1, 2, 3, and 4 in the PHP application prior to constructing your SQL statement and passing it to MySQL.
Furthermore, if your application does not support the generation of random numbers (although I am pretty sure it does), you could always retrieve random numbers from the MySQL built in function RAND() by issuing SELECT RAND() statements (although this approach is more inefficient as it consumes bandwidth). Neil On Sun, 12 May 2002, John Holmes wrote: > I don't know if this will work or not, but try > > SELECT * FROM table ORDER BY id, RAND(); > > That should keep all of the questions and answers together, but give a > random order for the answers.. ?? Like I said, not exactly sure on it > though. > > Best option, like someone else said, is to split this up into two > tables. > > ---John Holmes... > > > -----Original Message----- > > From: Jule [mailto:[EMAIL PROTECTED]] > > Sent: Sunday, May 12, 2002 1:28 PM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > > [EMAIL PROTECTED] > > Subject: Re: [PHP] random order > > > > hmm it got a little more complicated now, > > i have a table with: id title question answer1 answer2 answer3 > answer4. > > how can i use all of those in a php page but only randomize the > answers? > > > > so i get > > > > title title > > > > question question > > > > answer3 answer4 > > answer2 answer1 > > answer4 answer3 > > answer1 answer2 > > > > any ideas? > > thanks, > > > > Jule > > On Sunday 12 May 2002 17:30, you wrote: > > > Add on a LIMIT to restrict it to return a certain number of rows. > > > > > > If you had a table of say, 100 rows, and you wanted four random ones > out > > > of the 100, then you'd use this: > > > > > > SELECT * FROM table ORDER BY RAND() LIMIT 4; > > > > > > ---John Holmes... > > > > > > > -----Original Message----- > > > > From: Jule [mailto:[EMAIL PROTECTED]] > > > > Sent: Sunday, May 12, 2002 11:22 AM > > > > To: [EMAIL PROTECTED] > > > > Subject: Re: [PHP] random order > > > > > > > > Thanks John, > > > > I thought that that command only selected a random row.. > > > > must've read wrong. > > > > thanks. > > > > > > > > Jule > > > > > > > > On Sunday 12 May 2002 17:21, you wrote: > > > > > Nothing to do with PHP... > > > > > > > > > > SELECT * FROM table ORDER BY RAND(); > > > > > > > > > > ---John Holmes... > > > > > > > > > > > -----Original Message----- > > > > > > From: Jule [mailto:[EMAIL PROTECTED]] > > > > > > Sent: Sunday, May 12, 2002 9:49 AM > > > > > > To: [EMAIL PROTECTED] > > > > > > Subject: [PHP] random order > > > > > > > > > > > > Hey guys and gals, > > > > > > I have a problem: > > > > > > I have a mysql databse with 4 rows, and each row (row1, row2, > > > > > > row3, > > > > > > > > and > > > > > > > > > > > row4) > > > > > > contains a sentence. now i want these sentences to appear in > > > > > > random > > > > > > > > order: > > > > > > instance: 1 2 etc. > > > > > > row2 row4 > > > > > > row4 row2 > > > > > > row1 row1 > > > > > > row3 row3 > > > > > > > > > > > > how do i go about that?? > > > > > > any ideas apreciated. > > > > > > thanks > > > > > > > > > > > > Jule > > > > > > -- > > > > > > > > > > > > |\/\__________________________/\/| > > > > > > | Jule Slootbeek | > > > > > > | [EMAIL PROTECTED] | > > > > > > | http://blindtheory.cjb.net | > > > > > > | __________________________ | > > > > > > |/\/ \/\| > > > > > > > > > > > > -- > > > > > > PHP General Mailing List (http://www.php.net/) > > > > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > > > > > > > > |\/\__________________________/\/| > > > > | Jule Slootbeek | > > > > | [EMAIL PROTECTED] | > > > > | http://blindtheory.cjb.net | > > > > | __________________________ | > > > > |/\/ \/\| > > > > -- > > |\/\__________________________/\/| > > | Jule Slootbeek | > > | [EMAIL PROTECTED] | > > | http://blindtheory.cjb.net | > > | __________________________ | > > |/\/ \/\| > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php