Fix #6 SQL error when query has no results