Re: MySQL: Random select with specific count of a column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Rui Cunha" <rui.cunha@xxxxxx> wrote in message
news:20040630091042.AFC6D156CE@xxxxxxxxxxxxxx
> Hi Torsten,
>
> until now,the best i could get was getting 6 random rows...still working
on
> ensuring to retrive just 2 rows for category...meanwhile,you can solve the
> problem easily with a php loop trough the following query:
>
> select field_id , language , category
> from yourtable
> where language = 'de'
> group by category , field_id
> order by category , rand()
> limit 6;
>
> PS1: i'm considering you're using just one table and my table structure is
> as follows: yourtable (field_id , language, category).
> in case you're using more than 1 table, just add the required joins...
>
> hope this helps.

Hi Rui,

thank you very much for your efforts. I guess I have to do seperate queries
(as you suggested) for each category and then join the results.

Thanks again and best regards,

Torsten

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux