Page 277 - PYTHON-12
P. 277

mysql> Select Count(Ecode) from Employee;


                       Output: 5          (No NULL value exists in the column Ecode.)
              mysql> Select Count(Salary) from Employee;

                       Output: 3          (NULL values are ignored while counting the total number of records
                                          on the basis of Salary. )
              a.  SQL JOINS


                   An SQL JOIN clause is used to combine rows from two or more tables, based on a common field
                 between them. While querying for a join, more than one table is considered in FROM clause.
                 The process/function of combining data from multiple tables is called a JOIN. SQL can extract
                 data from two or even more than two related tables by performing either a physical or virtual
                 join on the tables using WHERE clause. The types of SQL joins are as follows:

                 1.  Cartesian Product (Cross Product)
                 2.  Equi Join

                 3.  Self Join
                 4.  Non-Equi Join

                 5.  Natural Join
              12.18.1 Cartesian Product (Cross Product)


              The Cartesian product is also termed as cross product or cross-join. The Cartesian product is a
              binary operation and is denoted by (X). The degree of the new relation formed is the sum of the
              degrees of two relations on which Cartesian product is performed. The number of tuples in the
              new relation is equal to the product of the number of tuples of the two tables on which Cartesian
              product is performed.
              For example,

              If A= {1,2,3} and B={a,b,c}, find A X B.
                                                     C = A X B
                                                                           (1,a)
                                                                           (1,b)
                                                                           (1,c)
                                           A              B                (2,a)
                                                                           (2,b)
                                           1               a               (2,c)

                                                                           (3,a)
                                           2       X       b      =        (3,b)
                                                                           (3,c)
                                           3               c

                                                   Cartesian Product for A X B

                                Table: student                      Table: games
                                  Rollno      Name                   gameno      gname
                                     1    Rohan                        10     Football                            Relational Database and SQL
                                     2    Jaya                         11     Lawn tennis
                                     3    Teena


                                                                                                            12.47
   272   273   274   275   276   277   278   279   280   281   282