Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
データベースにクエリを実行して、たとえば、上位 16 の順序付けられた結果 (rank と呼ばれるフィールドで順序付け) をランダムな順序で返すようにしようとしています。
php を使用して、返された (および順序付けられた) 16 個の結果をシャッフルして、php が使用する配列を調整することで、これを簡単に行うことができます。クエリ自体で直接これを行う簡単な方法があるかどうか疑問に思っています。
試す
select * from ( select * from your_table order by rank limit 16 ) x order by rand()