Issue with Query JSON with joins

Hello, I'm trying to join three different tables, however, I see a weird behavior that I don't know how to work around.

I'm pulling in a JSON via API, and I'm trying to join three together.

The master table has:

id, first_name, department_id, role_id

Each of the two detail tables contains:

id, name

Here's my join SQL:

select * from {{forecast_persons.data}} as u

join {{forecast_roles.data}} as r
	on u.default_role = r.id
  
join {{forecast_departments.data}} as d
	on u.department_id = d.id;

It seems to overwrite the "name" column with the last join, no matter what I do, please help me fix this (I'm a newbie). There should be a column for Department Name and a column for Role

Thank you!

Just figured it out - my SQL was wrong:

Should have been declared better:

select u.first_name, u.last_name, u.email, r.name as rname, d.name as dname from {{forecast_persons.data}} as u

join {{forecast_roles.data}} as r
	on u.default_role = r.id
  
join {{forecast_departments.data}} as d
	on u.department_id = d.id;