CROSS JOIN:
SELECT
Movies.CustomerID, Movies.Movie, Customers.Age,
Customers.Gender, Customers.[Education Level],
Customers.[Internet Connection], Customers.[Marital Status],
FROM
Customers
CROSS JOIN
Movies
INNER JOIN:
SELECT
Movies.CustomerID, Movies.Movie, Customers.Age,
Customers.Gender, Customers.[Education Level],
Customers.[Internet Connection], Customers.[Marital Status]
FROM
Customers
INNER JOIN
Movies ON Customers.CustomerID = Movies.CustomerID
Cross join does not combine the rows, if you have 100 rows in each
table with 1 to 1 match, you get 10.000 results, Innerjoin will only
return 100 rows in the same situation.
These 2 examples will return the same result:
Cross join
These 2 examples will return the same result:
Cross join
select * from table1 cross join table2 where table1.id = table2.fk_id
Inner joinselect * from table1 join table2 on table1.id = table2.fk_id
Use the last method
Here is the best example of Cross Join and Inner Join.
Consider the following tables TABLE : Teacher
TABLE : Student
1. INNER JOINInner join selects the rows that satisfies both the table.Consider we need to find the teachers who are class teachers and their corresponding students. In that condition, we need to apply JOIN or INNER JOIN and will Query
Result
2. CROSS JOINCross join selects the all the rows from the first table and all the rows from second table and shows as Cartesian product ie, with all possibilitiesConsider we need to find all the teachers in the school and students irrespective of class teachers, we need to apply CROSS JOIN .Query
Result
|
0 Comments