In what circumstances will you use UNION over CROSS JOIN and vice versa?
Hi Adolfo!
Great to have you in the course and thanks for reaching out!
These represent two very different functionalities provided by MySQL
UNION
is used whenever you want to simply combine data vertically. This means that UNION
shall be used whenever you have two tables or two sets of data that share identical fields, so that the first set can be, so to speak, extended by the data from the second set.
CROSS JOIN
is about matching all records from the designated tables. This type of join is also used whenever you are in the stage of making analysis and would simply like to exploit the number of possible combinations.
I am sure going through these videos once more and completing all provided exercises will make you a more confident user of both structures.
Hope this helps.
Best,
365 Team