[ticket/11253] Put AND clause in correct SQL query

PHPBB3-11253