General Note:

Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

Cross join is used to retrieve data from more than one table. However, it will not have any condition to join table. So for each record in one table, it will return all the records from another table. So if you cross join table1(m records) with table2(n records) the result will be multiplication(m*n) of m and n rows The mobile sales table cross joined with mobile rating table. Each table has 67 records. So the cross join will produce 67*67(4489) rows as result.


Select 

mobile_sales_details.mobile_name,price,brand_name,star5 

from

 mobile_sales_details 

 cross join

 mobile_rating

In the above query we have used table name with column mobile name.If you skip the mobile_sales_details before the mobile_name, it will throw an error because both the table has the same column name



mobile_name             price       brand_name star5    

---------------------- ---------- ---------- ----------

Moto X (16 GB) (Black) 23999       Motorola   20072    

Moto X (16 GB) (Black) 23999       Motorola   2078    

Moto X (16 GB) (Black) 23999       Motorola   12900    

Moto X (16 GB) (Black) 23999       Motorola   195      

Moto X (16 GB) (Black) 23999       Motorola   465      

Moto X (16 GB) (Black) 23999       Motorola   114      

Moto X (16 GB) (Black) 23999       Motorola   74      

Moto X (16 GB) (Black) 23999       Motorola   368      

Moto X (16 GB) (Black) 23999       Motorola   981      

Moto X (16 GB) (Black) 23999       Motorola   348      

Moto X (16 GB) (Black) 23999       Motorola   981      

Moto X (16 GB) (Black) 23999       Motorola   516      

Moto X (16 GB) (Black) 23999       Motorola   393      

Moto X (16 GB) (Black) 23999       Motorola   128      

Moto X (16 GB) (Black) 23999       Motorola   38      

Moto X (16 GB) (Black) 23999       Motorola   574      

Moto X (16 GB) (Black) 23999       Motorola   216      

Moto X (16 GB) (Black) 23999       Motorola   8        

Moto X (16 GB) (Black) 23999       Motorola   613      

Moto X (16 GB) (Black) 23999       Motorola   184      

Moto X (16 GB) (Black) 23999       Motorola   1102    

Moto X (16 GB) (Black) 23999       Motorola   150      

Moto X (16 GB) (Black) 23999       Motorola   1505    

Moto X (16 GB) (Black) 23999      Motorola   1543    

Moto X (16 GB) (Black) 23999       Motorola   4773    

Moto X (16 GB) (Black) 23999       Motorola   476      

Moto X (16 GB) (Black) 23999       Motorola   221      

Moto X (16 GB) (Black) 23999       Motorola   119      

Moto X (16 GB) (Black) 23999       Motorola   335      

Moto X (16 GB) (Black) 23999       Motorola   774      

Moto X (16 GB) (Black) 23999       Motorola   321      

Moto X (16 GB) (Black) 23999       Motorola   65      

 

Cross join is rarely used because it will not produce proper result.