SELECT `access`.`id`,IFNULL(`user_access`.`read`,0) AS `ur`,IFNULL(`user_access`.`edit`,0) AS `ue`,IFNULL(`access`.`read`,0) AS `dr`,IFNULL(`access`.`edit`,0) as `de`,`access`.`read_g` as `nr`,`access`.`edit_g` as `ne` FROM `access` LEFT JOIN `user_access` ON (`access`.`id`=`user_access`.`access_id`) AND (`user_access`.`user_id`=0) GROUP BY `access`.`id`