Page 55 - Modular_V2.0_SQL_Flipbook
P. 55
Rule Summary (for any two tables):
Columns = Number of columns in Table A (C1) + Number of columns in Table B (C2)
Total Columns = C1 + C2
Rows = Number of rows in Table A (R1) × Number of rows in Table B (R2)
Total Rows = R1 × R2
Let us consider another Table EMPLOYEE and STUDENTS:
Table-EMPLOYEE
Emp_id Emp_name Designation Salary City
101 Rahim VP 200000 Agra
102 Raja Manager 150000 Delhi
103 Riya Manager 150000 Agra
Table-STUDENTS
Stu_id Stu_name Subject_group DOB Age
101 Rahim Arts 2010-10-10 22
102 Raja Commerce 1999-01-08 23
103 Rita Science 2001-03-12 21
Select * from EMPLOYEE, STUDENTS;
Output:
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| Emp_id | Emp_name | Designation | Salary | City | Stu_id | Stu_name | Subject_group | DOB | Age |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 103 | Riya | Manager | 150000 | Agra | 101 | Rahim | Arts | 2010-10-10 | 22 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 102 | Raja | Manager | 150000 | Delhi | 101 | Rahim | Arts | 2010-10-10 | 22 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 101 | Rahim | VP | 200000 | Agra | 101 | Rahim | Arts | 2010-10-10 | 22 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 103 | Riya | Manager | 150000 | Agra | 102 | Raja | Commerce | 1999-01-08 | 23 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 102 | Raja | Manager | 150000 | Delhi | 102 | Raja | Commerce | 1999-01-08 | 23 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 101 | Rahim | VP | 200000 | Agra | 102 | Raja | Commerce | 1999-01-08 | 23 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 103 | Riya | Manager | 150000 | Agra | 103 | Rita | Science | 2001-03-12 | 21 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 102 | Raja | Manager | 150000 | Delhi | 103 | Rita | Science | 2001-03-12 | 21 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
| 101 | Rahim | VP | 200000 | Agra | 103 | Rita | Science | 2001-03-12 | 21 |
+--------+----------+-------------+--------+-------+--------+----------+---------------+------------+------+
This table is the result of cross join or cartesian product between two tables.
Now consider the following tables:
Table-GAMES
Games_no Game_played Game_id
10 Cricket 1000
11 Rugby 1001
12 Football 1002
53
Advanced Features of MySQL

