Fix sql query for users index