Removing sql query that can't work