Shendemiar
Morkin Admin
Mmmm, free goo!
Posts: 6,751
|
Post by Shendemiar on Sept 21, 2007 15:02:47 GMT
######################################################################################################## # This gets the daycount id of the last day that had all map readings done. function DB_latest_day(){ $query = fetch_query("SELECT DISTINCT(daycount) AS dc FROM `system_jobs` WHERE daycount NOT IN (SELECT daycount FROM `system_jobs` WHERE done=0) ORDER BY daycount DESC LIMIT 1"); $rivi = mysql_fetch_assoc($query); $latest = $rivi['dc']; return $latest; }
It takes 4 seconds... Someone re-write it using left joins and stuff thats too complicated for me.
|
|
Shendemiar
Morkin Admin
Mmmm, free goo!
Posts: 6,751
|
Post by Shendemiar on Sept 21, 2007 15:18:11 GMT
Solved:
######################################################################################################## # This gets the daycount id of the last day that had all map readings done. function DB_latest_day(){ $query = fetch_query("SELECT daycount, count(done) as cdone FROM `system_jobs` WHERE done=1 GROUP BY daycount ORDER BY cdone DESC, daycount DESC LIMIT 1"); $rivi = mysql_fetch_assoc($query); $latest = $rivi['daycount']; return $latest; }
Well this sort of dont work if not any of the days ever are finished... but i take that flaw without a problem...
|
|