Introduction
A CROSS JOIN combines every row from one table with every row from another table. It helps to see all possible pairs between two sets of data.
SELECT * FROM table1 CROSS JOIN table2;
SELECT * FROM fruits CROSS JOIN colors;
SELECT employees.name, projects.title FROM employees CROSS JOIN projects;
CREATE TABLE fruits (name VARCHAR(10)); INSERT INTO fruits VALUES ('Apple'), ('Banana'); CREATE TABLE colors (color VARCHAR(10)); INSERT INTO colors VALUES ('Red'), ('Yellow'); SELECT fruits.name, colors.color FROM fruits CROSS JOIN colors;
CROSS JOIN do in MySQL?Table A: idTable B: colorSELECT * FROM A CROSS JOIN B;?SELECT * FROM employees CROSS JOIN departments ON employees.id = departments.id;Products (product_id, name) with 3 rows,Colors (color_id, color_name) with 4 rows.Pass the test and this pattern moves unknown