Joining Two Tables on Multiple Ids
Hello all,
I'm guessing there is an obvious solution for this, but definitely not an expert in sql.
On our Deals module, we have two user lookup fields. In Analytics, those fields have the user's ids in those table rows, and I'm trying to create a query that returns both of the user's names. I know I need to join the Deals table to the Users table, but I'm not sure how to make it return the different names. Here's an example of the way I'm writing the query..
- SELECT
"Deals"."Name", - "Deals"."Producer",
- "Deals"."Agent",
- "Users"."Full Name" AS 'Producer',
- "Users"."Full Name" AS 'Servicing Agent'
- FROM "Deals"
- LEFT JOIN "Users" on "Users"."Id" = "Deals"."Agent"
I know I need to add more to line 7, but it seems like every way I try it, I just get the same name back twice.
Any help is appreciated!