开发者

help on mysql query JOIN, ORDER BY and randomize

开发者 https://www.devze.com 2023-01-27 19:07 出处:网络
i am joining 2 tables using this query SELECT DISTINCT (member.id), member_type FROM member LEFT JOIN member_gallery

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消