I have a table A with the records: A, B, C I have another table B with the records: 4, 2, 1 I need to get a list with the combined records: A 4, A 2, A 1, B 4, B 2, B 1, C 4, C 2, C 1 How would a SELECT be to obtain this?
I have a table A with the records: A, B, C I have another table B with the records: 4, 2, 1 I need to get a list with the combined records: A 4, A 2, A 1, B 4, B 2, B 1, C 4, C 2, C 1 How would a SELECT be to obtain this?
You are talking about a cartesian product:
Although it is not very common to find it, it is very useful that you know it to solve certain situations that are resolved with this operator.
You can also build it with a
JOIN
, withoutON
orUSING
, instead of the,
.