Fixed a minor bug with sql_query