Cartesian product: – In many cases, user may require to retrieve data from multiple table. Suppose we want to retrieve employee name, salary and living city then we have to get data from tables employee and company. Cartesian product is useful in SQL to retrieved data from multiple table. We can use Cartesian product in the following format –
Select a.ename,a.salary,b.city from employee a, company b where a.city=‘Delhi’ and a.cname=b.cname;
In case of above example, ename, salary and city column values are listed from both tables employee and company only when city column of table company is Delhi and company name of both employee and company table are same.