开发者

Direct product of two tables

开发者 https://www.devze.com 2023-01-16 05:27 出处:网络
When is direct product of two tables useful? Seems like an 开发者_StackOverflow社区academic thing.Check out What are the uses for cross join?There are some uses for it. Let\'s say there is a clothing

When is direct product of two tables useful? Seems like an 开发者_StackOverflow社区academic thing.


Check out What are the uses for cross join?


There are some uses for it. Let's say there is a clothing store selling T-Shirts in different colours and different sizes. Each combo has it's own SKU.

If there is a table Products that references tables Sizes and Colors then

You could get list of all possible products with:

SELECT * FROM Products, Colors, Sizes

Okay that is actually quite academic.


Some times you want to get every possible combination of rows that match certain criteria. The way to do it is cross-join and then filter out rows that do not match the criteria.

Inner/Outer joins are just a special case of this: the desired criteria is "the data of table 1 is related to the data in table2..."

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号