Question
SQL Join Help Please
Hi,
I am joining three tables. ContentTypes, cmsSchemas and Relation.
This join is a many to many relationship. The ID of a content type is stored in a row on the relation table, and it's corresponding cmsSchema ID is stored alongside this. So, the relation table basically contains a long list of relationships between ContentTypes and cmsSchemas.
A content type can have many schemas, and different content types can have the same schema.
What I want to output is the following:
Content type 1
-------------------------
schema 1
schema 2
Content type 2
-------------------------
schema 2
BUT, what I am getting is the following:
Content type 1
-------------------------
schema 1
Content type 1
-------------------------
schema 2
Content type 2
-------------------------
schema 2
So, basically, what I want to do, is output a list of content types with the associated schemas beneath them. But because my relation table contains lots of rows for each association, I'm getting each one.
Any help on modifying my query would be greatly appreciated.
Please note, my term "schema" should not be confused with the database definition of "schema"...just look at it as a name like any other.
Many thanks,
Mikey.
I am joining three tables. ContentTypes, cmsSchemas and Relation.
This join is a many to many relationship. The ID of a content type is stored in a row on the relation table, and it's corresponding cmsSchema ID is stored alongside this. So, the relation table basically contains a long list of relationships between ContentTypes and cmsSchemas.
A content type can have many schemas, and different content types can have the same schema.
What I want to output is the following:
Content type 1
-------------------------
schema 1
schema 2
Content type 2
-------------------------
schema 2
BUT, what I am getting is the following:
Content type 1
-------------------------
schema 1
Content type 1
-------------------------
schema 2
Content type 2
-------------------------
schema 2
So, basically, what I want to do, is output a list of content types with the associated schemas beneath them. But because my relation table contains lots of rows for each association, I'm getting each one.
Any help on modifying my query would be greatly appreciated.
Please note, my term "schema" should not be confused with the database definition of "schema"...just look at it as a name like any other.
Many thanks,
Mikey.
