Hi all,
I'm having a quite stupid MySQL problem. First look at the following:
mysql> select * from groups;
+---------+-------+------+-------+
| groupid | type | lang | categ |
+---------+-------+------+-------+
| 1 | frame | de | a |
| 1 | frame | de | b |
| 1 | frame | de | c |
| 1 | frame | de | d |
| 2 | frame | de | e |
| 2 | frame | de | f |
| 3 | frame | de | g |
+---------+-------+------+-------+
7 rows in set (0.00 sec)
So when I group the items by groupid I get the following result:
mysql> select * from bannerindex group by groupid;
+---------+-------+------+-------+
| groupid | type | lang | categ |
+---------+-------+------+-------+
| 1 | frame | de | a |
| 2 | frame | de | e |
| 3 | frame | de | g |
+---------+-------+------+-------+
3 rows in set (0.00 sec)
Now let's get to my problem. I want to select one row for different groupids each time I do the query.
If I'd select a random row from the topmost results I'd get - for example - a row for groupid 1 the first query, another one for groupid 1 again the next query, then maybe a row for groupid 2, one for id 1 again, maybe one for 3, ... the groupid usage is unbalanced.
But I'd like to select another random row per groupid each query. I hope you understand me and my lousy English 🙁