Change search over to SQL statement