In Oracle and MariaDB, the CROSS JOIN clause allows you to perform a cartesian product (cross-product) i.e. join each row from the first table with each row from the second table.
Consider sample data:
-- Sample tables CREATE TABLE colors (name VARCHAR(30)); CREATE TABLE products (name VARCHAR(30)); -- Sample rows INSERT INTO colors VALUES ('Green'); INSERT INTO colors VALUES ('Red'); INSERT INTO colors VALUES ('Yellow'); INSERT INTO products VALUES ('Apple'); INSERT INTO products VALUES ('Cherry');
Oracle and MariaDB:
-- Cartesian product of two tables SELECT c.name, p.name FROM colors c CROSS JOIN products p;
Result:
| c.name | p.name | 
| Green | Apple | 
| Red | Apple | 
| Yellow | Apple | 
| Green | Cherry | 
| Red | Cherry | 
| Yellow | Cherry | 
For more information, see Oracle to MariaDB Migration.