PHP mysqli select by group and random -


not sure if possible. trying mysqli query work group results , inside each group display results randomly. here current code produces results in random order.

select * swt_counties_members     county_id=".$scounty[1]."  ,    status=1  or    county_id=0  ,    status=1  order rand() 

what need group service_id , display random records in each group. this

select * swt_counties_members     county_id=".$scounty[1]."  ,    status=1  or    county_id=0  ,    status=1  group service_id  order rand() 

where group results first service_id , display results in each of group randomly

hope makes sense :) many thanks

you want order by, not group by

select * swt_counties_members county_id=".$scounty[1]." , status=1 or county_id=0 , status=1 order service_id,rand() 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -