Update SQL to get users and filter properly