php - Find out how often a value is between 2 dates in mysql -
hi follow code request dates in database without duplicates. save array. in array need other value.
the value need how users in 1 day in database without duplicates. example array must later lookslike 23.07.2013 - 10, 24.07.2013 - 50 (users). search several hours don't find mysql query.
$query = "select id, user, timestamp stat timestamp between '$datum1' , '$datum2' group timestamp"; $result = mysql_query($query,$db); while($row = mysql_fetch_assoc($result)) { mysql_num_rows($result); $dataset1[] = array(strtotime($row['timestamp']),$number_of_users_on_this_day); }
try:
$query = "select id, user, count(*) count stat timestamp between '$datum1' , '$datum2' group timestamp";
this return number of entries in value 'count'
if want distinct data, in place of * use
count(distinct id)
with whatever field want unique in place of 'id'
Comments
Post a Comment