I'm not interested in "Join" concept yet. I'm trying to figure what really happens underneath when using:
select * from table1, table2
.
I've built two tables, numbers
and letters
:
When using select * from numbers, letters
, the output is:
I jumped to the conclusion that SQL matches every row from first table to the second table, by pointing some kind of iterator 1 from last row to first row on the first table, then first row to last row on second table 1, resetting 1s position back to the end of first table each time 2 reaches a new position.
The same happens when inverting letters first, number last:
However I believe I'm wrong, as when I inserted more values to numbers
, the follow happened:
In that try, even though the query selects numbers, letters
, numbers got "fixed" and letters got "reverse iterated", not the other way around.
Being honest, what I was really expecting first place when selecting numbers, letters
was something like:
1 a
1 b
1 c
2 a
2 b
2 c
3 a
3 b
3 c
What really happens underneath when selecting multiple values? I found many answers concerning how to use joins to achieve x result, but not so much content talking about what SQL is generating with the original query first place.
Thanks a lot in advance!