The CROSS JOIN keyword returns the Cartesian product of two or more tables — every row from the first table combined with every row from the second table. If table1 has n rows and table2 has m rows, the result set contains n × m rows. Useful for generating combinations or test data, but use carefully (can grow very large).
ON — it produces combinations.
-- Syntax for CROSS JOIN (returns Cartesian product)
SELECT columns
FROM table1
CROSS JOIN table2;
-- Get all possible combinations of products and suppliers
SELECT products.product_name, suppliers.supplier_name
FROM products
CROSS JOIN suppliers;
-- Get all possible combinations of employees and departments
SELECT employees.name, departments.department_name
FROM employees
CROSS JOIN departments;
If products has 4 rows and suppliers has 3 rows, the CROSS JOIN query above returns 12 rows — every product paired with every supplier. There is no filtering; include WHERE if you want to trim results after forming the Cartesian product.
product_name: "Pen" — paired with supplier A, B, Cproduct_name: "Notebook" — paired with supplier A, B, CCROSS JOIN can produce extremely large result sets when tables are large.INNER JOIN or LEFT JOIN.VALUES to limit growth.products and customers.CROSS JOIN to combine a list of courses with students (small sample).CROSS JOIN vs. an INNER JOIN on similar tables to see differences.