Skip to content

Instantly share code, notes, and snippets.

@emilsedgh
Created May 25, 2017 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilsedgh/d602d37c14794236f4fac3a3c8088bcc to your computer and use it in GitHub Desktop.
Save emilsedgh/d602d37c14794236f4fac3a3c8088bcc to your computer and use it in GitHub Desktop.
SELECT DISTINCT agents.id AS id FROM agents
LEFT JOIN users ON agents.id = users.agent
LEFT JOIN offices ON agents.office_mui = offices.matrix_unique_id
LEFT JOIN brands_offices ON offices.id = brands_offices.office
LEFT JOIN brands_users ON users.id = brands_users.user
WHERE (
(
brands_offices.brand = '745e77aa-4ddf-11e6-a07d-f23c91b0d077'
)
OR
(
brands_users.brand = '745e77aa-4ddf-11e6-a07d-f23c91b0d077'
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment