Fix break in SQL query