I have a question on how to bind data to a datagridview in C# when using a JOIN query with a mySql datasource, and I return one unique record from the first table and 0-2 records from a second table. My query is as follows:
SELECT t1.*, t2.org_id, t2.org_name
FROM test.tbl_user_accounts AS t1
INNER JOIN test.tbl_organizations AS t2
ON t1.affiliation_one = t2.org_id OR t1.affiliation_two = t2.org_id;
It’s a school assocation, where a user can be associated with up to two schools. I want the schools to display in separate cells so a GROUP_CONCAT isn’t really a good option, and if I use GROUP BY on the t1.user_id field then I lose the second affiliation. If I don’t group, I end up with two rows for the same user.
I’m not all that familiar with joins, so it’s possible that a different type of join might solve this?
I’m using Visual C# 2010, with a mySql datasource.
Here’s the query I used to solve this (I think I found it in another stack post, actually).