User:Slakr/Temp/sql2

SELECT STRAIGHT_JOIN pr.*, p.page_title, l.*, IFNULL(l.log_timestamp, 0) AS lTime, u.user_name

FROM page_restrictions AS pr       RIGHT JOIN page AS p ON (                pr.pr_page = p.page_id        ) LEFT JOIN logging AS l ON (               l.log_namespace = p.page_namespace                AND l.log_title = p.page_title                AND l.log_type = 'protect'                AND l.log_action = 'protect'        ) LEFT JOIN user AS u ON (               u.user_id = l.log_user        ) WHERE pr.pr_type = 'edit' AND pr.pr_level = 'autoconfirmed' AND pr.pr_expiry = 'infinity' AND p.page_namespace = 0

GROUP BY p.page_id

HAVING MAX(lTime) = lTime