MODX Community

MIGX-CMP Join Statements

Summary

I saw a post on the old forum that never got answered and I’m running into the same problem, but I want to know how these join statements work: https://forums.modx.com/thread/97929/need-some-help-with-migx-front-end-joins

1 Like

the answer for his question would be:

[{"alias":"Profile","classname":"modUserProfile","on":"Profile.internalKey = Downloads.user_id"}]
1 Like

Thank you for your response! I’d like to figure out how to do this one thing that’s still stumping me. So I have a projects table that lists an “agency_id” (the user ID) and I’d like to join that table with the user attributes table to print the fullname of that user in a column. How would I do that using join?

Here’s my current join that doesn’t work:
[{“alias”:“Profile”,“classname”:“UserAttributes”,“on”:“Profile.id = AgencyProjects.agency_id”}]

Here’s the schema of the two tables I’d like to join:

	<index alias="internalKey" name="internalKey" primary="false" unique="true" type="BTREE" >
		<column key="internalKey" length="" collation="A" null="false" />
	</index>
</object>
	<index alias="agency_id" name="agency_id" primary="false" unique="false" type="BTREE" >
		<column key="agency_id" length="" collation="A" null="true" />
	</index>
</object>
1 Like

If this isn’t possible with MIGX it will be possible to output that data with a snippet I think, just fyi

I’ve heard you could do that, but I’m also 99% sure you can make join statements in Migx-db, I just don’t understand it too well. The problem I have with using snippets to display data in the grid is that they don’t export when you export the view; you just get the plain number or whatever was there before.

it has to be like that:

[{"alias":"Profile","classname":"modUserProfile","on":"Profile.internalKey = AgencyProjects.agency_id"}]

the classname is modUserProfile and the user - id is internalKey

Yes, inserting other things into the routine is hard, that’s precisely why I mentioned it :wink: