Sql query image fix