Beginners Guide to Understanding Cross Join
In my previous Beginners Guide we talked about Types of joins i.e.
Inner Join, Left and Right Join but today we will be talking about cross join which happens to be more interesting to me than any other joins and happens to be helpful in real time for me.
What is a CROSS JOIN?
A CROSS JOIN is a JOIN operation that produces the Cartesian product of two tables.
Why CROSS JOIN?
Let’s say we have two table employee table “emp1” and department table “dept” now lets see how many records do we have in the emp1 table:
and for the emp1 table you want to “associate” the location column from the
dept table to all the records in the emp1 table so we use CROSS JOIN
but really why ?
In realtime Sometimes you might want to associate dates with a particular table and its records this happens to be helpful
And there you go hope you will have a better understanding now.