Skip to content
Advertisement

MySQL query to get all users belonging to an organization

I have a fairly large database (that I didn’t design) that I need to get some data from. I need to find all users belonging to an organization. There is a users table that looks like this;

and an organisation table like this;

and a user_orgs table through which the other tables are related;

Given an org_number, I would like to be able to get the name and email address of each user in that organization.

I have tried

Along with a bunch of other queries and I know there should be 20 users registered to the organization number 123456, but it returns empty.

How can I do this?

Advertisement

Answer

Your JOIN conditions do not look correct:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement