File tree 3 files changed +96
-0
lines changed
3 files changed +96
-0
lines changed Original file line number Diff line number Diff line change
1
+ Cross JOIN/Cartesian Join/ Cartesian Product/Cross Product
2
+ -> The cross join returns every row from one table crossed with every row from the second.
3
+ syntax: SELECT * FROM emp CROSS JOIN student;
4
+ :SELECT name,sname FROM emp CROSS JOIN student;
5
+
6
+ ex:select name, dob from student_reg, new;
7
+ +---------+------------+
8
+ | name | dob |
9
+ +---------+------------+
10
+ | RAM | 1998-12-15 |
11
+ | RAM | 1998-12-15 |
12
+ | RAM | 1998-12-15 |
13
+ | RAM | 1998-12-15 |
14
+ | SITA | 2001-10-11 |
15
+ | SITA | 2001-10-11 |
16
+ | SITA | 2001-10-11 |
17
+ | SITA | 2001-10-11 |
18
+ | HARI | 2001-01-12 |
19
+ | HARI | 2001-01-12 |
20
+ | HARI | 2001-01-12 |
21
+ | HARI | 2001-01-12 |
22
+ | BIMAl | NULL |
23
+ | BIMAl | NULL |
24
+ | BIMAl | NULL |
25
+ | BIMAl | NULL |
26
+ | SITA KC | 1998-02-02 |
27
+ | SITA KC | 1998-02-02 |
28
+ | SITA KC | 1998-02-02 |
29
+ | SITA KC | 1998-02-02 |
30
+ +---------+------------+
Original file line number Diff line number Diff line change
1
+ INNER JOIN
2
+ -> An INNER JOIN is a cross JOIN with some result rows removed by a condition in the query.
3
+ .-> EQUIJOIN
4
+ .->NON-EQUIJOIN
5
+ .->NATURAL JOIN
6
+ 1.EQUIJOIN
7
+ ex:select new.student,student_reg.name from new INNER JOIN student_reg ON new.s_id = new.s_id;
8
+ +---------+---------+
9
+ | student | name |
10
+ +---------+---------+
11
+ | testing | RAM |
12
+ | Sita | RAM |
13
+ | Ram | RAM |
14
+ | Hari | RAM |
15
+ | testing | SITA |
16
+ | Sita | SITA |
17
+ | Ram | SITA |
18
+ | Hari | SITA |
19
+ | testing | HARI |
20
+ | Sita | HARI |
21
+ | Ram | HARI |
22
+ | Hari | HARI |
23
+ | testing | BIMAl |
24
+ | Sita | BIMAl |
25
+ | Ram | BIMAl |
26
+ | Hari | BIMAl |
27
+ | testing | SITA KC |
28
+ | Sita | SITA KC |
29
+ | Ram | SITA KC |
30
+ | Hari | SITA KC |
31
+ +---------+---------+
32
+
33
+ 2.NON-EQUIJOIN
34
+ ex: select student_reg.name,new.student from student_reg INNER JOIN new ON student_reg.s_id<>new.s_id;
35
+ +---------+---------+
36
+ | name | student |
37
+ +---------+---------+
38
+ | RAM | testing |
39
+ | RAM | Sita |
40
+ | RAM | Ram |
41
+ | RAM | Hari |
42
+ | SITA | testing |
43
+ | SITA | Sita |
44
+ | SITA | Ram |
45
+ | SITA | Hari |
46
+ | HARI | testing |
47
+ | HARI | Sita |
48
+ | HARI | Ram |
49
+ | HARI | Hari |
50
+ | BIMAl | testing |
51
+ | BIMAl | Sita |
52
+ | BIMAl | Ram |
53
+ | BIMAl | Hari |
54
+ | SITA KC | testing |
55
+ | SITA KC | Sita |
56
+ | SITA KC | Ram |
57
+ | SITA KC | Hari |
58
+ +---------+---------+
59
+
60
+ 3. NATURAL JOIN
61
+ ex:select column_name FROM table1 NATURAL JOIN table2;
Original file line number Diff line number Diff line change
1
+ // Outer join
2
+ -> An outer joins returns all rows from one of the tables, along gwith matching information from another table.
3
+ .-> LEFT OUTER JOIN / LEFT JOIN
4
+ .-> RIGHT OUTER JOIN/ RIGHT JOIN
5
+ .-> FULL OUTER JOIN / FULL JOIN
You can’t perform that action at this time.
0 commit comments