Dear All,
I have the following problem and I would be happy if somebody could help me with that: So far I had two tables. One contained customer orders, the other a description of each article. The connection between both tables was through a unique article name, which was the primary key of the ArticleDescription table. So far this worked.
But now it becomes more complicated, as there is no longer a n:1-relationship between the two tables Orders and ArticleDescription as each article now can have different specifications, which however to no relate to the items in the ArticleDescription table. That is, I have to include a table between those two tables.
Old situation:
tbOrders - Old
Order# // Article# // Date // Amount etc.
1 // A // 09/18/07 // 5
2 // B // 09/19/07 // 3
3 // A // 09/20/07 // 2
tbDescriptionArticle
Article# // Description etc.
A // Text1
B // Text2
An SQL query to combine information of both could for example look like the following...
...in order to get this output:
Order# // Article# // Description
1 // A // Text1
2 // B // Text2
3 // A // Text1
This changes now to:
tbOrders - New
Order# // Article#New // Date // Amount etc.
1 // A1 // 09/18/07 // 5
2 // B1 // 09/19/07 // 3
3 // A2 // 09/20/07 // 2
...and I have additionally a table, which includes the relationships
tbRelationships
Article#New // Article#
A1 // A
A2 // A
B1 // B
...while tbDescriptionArticles remains the same.
How does the SQL query change in order to achieve the same output as with the first query?
Thank you very much.
Diana
P.S. Does anybody know how to display tables in this forum more efficiently?
I have the following problem and I would be happy if somebody could help me with that: So far I had two tables. One contained customer orders, the other a description of each article. The connection between both tables was through a unique article name, which was the primary key of the ArticleDescription table. So far this worked.
But now it becomes more complicated, as there is no longer a n:1-relationship between the two tables Orders and ArticleDescription as each article now can have different specifications, which however to no relate to the items in the ArticleDescription table. That is, I have to include a table between those two tables.
Old situation:
tbOrders - Old
Order# // Article# // Date // Amount etc.
1 // A // 09/18/07 // 5
2 // B // 09/19/07 // 3
3 // A // 09/20/07 // 2
tbDescriptionArticle
Article# // Description etc.
A // Text1
B // Text2
An SQL query to combine information of both could for example look like the following...
Code:
Select tbOrders.Order#, tbOrders.Article#, tbDescriptionArticle.Description
From tbOrders Inner Join tbDescriptions On tbOrders.Article# = tbDescriptionArticle.Article#;
...in order to get this output:
Order# // Article# // Description
1 // A // Text1
2 // B // Text2
3 // A // Text1
This changes now to:
tbOrders - New
Order# // Article#New // Date // Amount etc.
1 // A1 // 09/18/07 // 5
2 // B1 // 09/19/07 // 3
3 // A2 // 09/20/07 // 2
...and I have additionally a table, which includes the relationships
tbRelationships
Article#New // Article#
A1 // A
A2 // A
B1 // B
...while tbDescriptionArticles remains the same.
How does the SQL query change in order to achieve the same output as with the first query?
Thank you very much.
Diana
P.S. Does anybody know how to display tables in this forum more efficiently?