Gossamer Forum
Quote Reply
ORDER BY RAND()
Anyone know why this isn't 'ordering' by rand() ? There are 3 entries in the SQL database, of which 2 of them should match. The appropriate code is;

Code:
# get the category ID we wanna use...
my $CatID = shift;

print "Checking for category $CatID<BR>";

my $banner;

# grab the stuff form the database...
my $table = $DB->table('CatAdverts');
$table->select_options ("ORDER BY RAND()",'LIMIT 1');
my $sth = $table->select( GT::SQL::Condition->new('Categories', 'LIKE', "% $CatID %") );

And the data in the MySQL database/table is;

Code:
SetID Title URL Categories
1 Test Title http://www.google.com 1 2 3 4 7 9 11
2 Test Title 2 http://www.google.com 1 2 3 4 7 9 11
3 test again http://www.google.com 3 4 1 2

Anyone got any ideas? I always brings up SetID 1 Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread ORDER BY RAND() Andy 4332 Jan 28, 2003, 3:52 AM
Thread Re: [Andy] ORDER BY RAND()
Paul 4246 Jan 28, 2003, 4:22 AM
Thread Re: [Paul] ORDER BY RAND()
Andy 4230 Jan 28, 2003, 4:25 AM
Thread Re: [Andy] ORDER BY RAND()
Andy 4221 Jan 28, 2003, 8:32 AM
Thread Re: [Andy] ORDER BY RAND()
webmaster33 4215 Jan 28, 2003, 6:14 PM
Post Re: [webmaster33] ORDER BY RAND()
Andy 4167 Jan 29, 2003, 2:14 AM
Thread Re: [Andy] ORDER BY RAND()
Paul 4199 Jan 29, 2003, 3:10 AM
Post Re: [Paul] ORDER BY RAND()
Andy 4193 Jan 29, 2003, 3:33 AM
Thread Re: [Andy] ORDER BY RAND()
pugdog 4162 Jan 30, 2003, 11:37 AM
Post Re: [pugdog] ORDER BY RAND()
Andy 4171 Jan 31, 2003, 1:13 AM