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;
> +----+---------+---------------+
> | id | user_id | title         |
> +----+---------+---------------+
> |  1 |       1 | first banner  |
> |  2 |       1 | second banner |
> |  3 |       2 | third banner  |
> |  4 |       2 | forth banner  |
> |  5 |       2 | fifth banner  |
> +----+---------+---------------+
> 
> I would like to show a random banner for each user,
> something like this:
> 
> first call
> +----+---------+---------------+
> | id | user_id | title         |
> +----+---------+---------------+
> |  1 |       1 | first banner  |
> |  3 |       2 | third banner  |
> +----+---------+---------------+
> 
> second call
> +----+---------+---------------+
> | id | user_id | title         |
> +----+---------+---------------+
> |  2 |       1 | second banner |
> |  4 |       2 | forth banner  |
> +----+---------+---------------+
> 
> etc...
> 
> I have tried with following query but 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]




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to