I think this fixes the query, at least temporarily, until we really fix the whole user/year system

This commit is contained in:
james 2009-12-04 17:22:55 +00:00
parent 8c5a0bd853
commit c3ed887dca

View File

@ -166,7 +166,7 @@ function neweditor()
/* Grab a list of users */ /* Grab a list of users */
$w = array(); $w = array();
foreach($show_types as $t) { foreach($show_types as $t) {
$w [] = "users.types LIKE '%$t%'"; $w [] = "u1.types LIKE '%$t%'";
} }
$where_types = "AND (".join(" OR ", $w).")"; $where_types = "AND (".join(" OR ", $w).")";
@ -178,22 +178,23 @@ function neweditor()
} }
if($show_year == 'current') if($show_year == 'current')
$having_year = "AND MAX(`users`.`year`)={$config['FAIRYEAR']}"; $having_year = "AND u1.year={$config['FAIRYEAR']}";
echo "<table class=\"tableview\">"; echo "<table class=\"tableview\">";
$querystr="SELECT $querystr="SELECT
*, MAX(`users`.`year`) as maxyear *
FROM FROM
users users u1
LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`users`.`id` LEFT JOIN `users_committee` ON `users_committee`.`users_id`=`u1`.`id`
LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`users`.`id` LEFT JOIN `users_judge` ON `users_judge`.`users_id`=`u1`.`id`
LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`users`.`id` LEFT JOIN `users_volunteer` ON `users_volunteer`.`users_id`=`u1`.`id`
LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`users`.`id` LEFT JOIN `users_fair` ON `users_fair`.`users_id`=`u1`.`id`
LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`users`.`id` LEFT JOIN `users_sponsor` ON `users_sponsor`.`users_id`=`u1`.`id`
WHERE u1.year=( SELECT MAX(`year`) FROM users u2 WHERE u1.uid=u2.uid )
GROUP BY uid GROUP BY uid
HAVING HAVING
users.deleted='no' u1.deleted='no'
$having_year $having_year
$where_types $where_types
$where_complete $where_complete