CREATE OR REPLACE VIEW view__roles as
select
  uhor.roleID,
  uhor.userID,
  uhor.main,
  or.organizationID,
  or.admin,
  o.partnerID
from
  smd__user_has_organization_role `uhor`
join
  smd__organization_role as `or`
on
  or.roleID = uhor.roleID
join
  smd__organization as `o`
on
  or.organizationID = o.organizationID