[ticket/13197] Correctly format sql query

PHPBB3-13197