Skip to content

Instantly share code, notes, and snippets.

@matthewpoer
Created April 15, 2014 13:09
Show Gist options
  • Save matthewpoer/10731237 to your computer and use it in GitHub Desktop.
Save matthewpoer/10731237 to your computer and use it in GitHub Desktop.
Select an Account and its Member Accounts (children)
-- select an account and its children
select parent.id,parent.name,child.parent_id,child.id,child.name from accounts parent
left join accounts child on child.parent_id=parent.id
where parent.deleted=0 and (child.deleted=0 or child.deleted is null)
order by parent.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment