Page 1 of 1

mysql problem with random value

Posted: Sat Jul 17, 2004 8:42 pm
by Bora
I have problem with get random id and total amount of rows for each kat.

Code: Select all

ID | KAT
 1    1
 2    3
 3    3 
 4    2
 5    2
 6    2
 7    1
 8    1

Code: Select all

SELECT COUNT(id), id, kat
FROM `table` GROUP BY kat
ORDER BY RAND()
GROUP always join rows selecting first rows. So it each time looks like this

Code: Select all

kat, COUNT(id), id
 1  , 3        , 1 
 2  , 3        , 4 
 3  , 2        , 2
How to solve this problem ?

Posted: Sat Jul 17, 2004 8:59 pm
by feyd
odd.. I don't remember having that sort of problem.. are you trying to access the data via numeric indices? You could switch to the named indices.. :?

Posted: Sun Jul 18, 2004 3:52 am
by Bora
could u show how this table looks ??? I try but when i'm using GROUP BY id is still fitst value

Posted: Sun Jul 18, 2004 10:40 am
by feyd
when I make a duplicate of that table strcture and query, I get the expected results, with 'COUNT( id )' as the first column..