fix sql query to retrieving urls