Fix unquoted variable in SQL query