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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -