Geek Slack

My SQL Tutorial
    About Lesson


    MySQL CROSS JOIN Keyword


    MySQL CROSS JOIN Keyword

    The CROSS JOIN keyword in MySQL returns the Cartesian product of two tables, which means it combines each row of the first table with every row of the second table.

    Example:

    SELECT customers.customer_name, orders.order_id
    FROM customers
    CROSS JOIN orders;

    This query retrieves customer names along with their order IDs, combining each customer with every order, resulting in all possible combinations.

    CROSS JOIN can be useful in scenarios where you need to generate all possible combinations of rows from two tables.