help on mysql query JOIN, ORDER BY and randomize
i am joining 2 tables using this query
SELECT DISTINCT (member.id), member_type FROM member
LEFT JOIN member_gallery
ON member.id = member_gallery.member_id
WHERE member.front = 1
ORDER BY member.member_type ASC
suppose that i have 4 member types
- 20 members for type no.1
- 20 members for type no.2开发者_开发百科
- 20 members for type no.3
- 20 members for type no.4
and i am displaying this on my web as a 6x5 image grid, is it possible for me to randomize the fetch data, while maintaining the ORDER BY member.member_type ASC, like using ORDER BY RAND() ?
thanks
Use
ORDER BY member.member_type ASC, RAND()
精彩评论