-- You have two tables, Table A and Table B. Which of the following correctly describes the result set
-- of a CROSS JOIN compared to a FULL JOIN 

-- A CROSS JOIN returns all combinations of rows from both tables (Every possible combination)
-- While a FULL JOIN returns all matching and non matching rows from both tables (LEFT, RIGHT JOIN)


-- Cross join is a type of join that returns the cartesian product of two tables. 
-- Means every row from the first table is combined with every row from the second table 

-- No ON condition is used 
-- If Table A has 3 rows and Table B has 4 rows, the result will have 3 x 4 = 12 rows 
-- Useful for generating combinations, but can produce very large result sets 

-- Difference between Cross JOIN and a full JOIN 

-- Cross JOIN -- Produces the cartesian proudct of two tables 
-- Every row in Table A is paired with every row in Table B 


-- No join condition is used 
-- If Table A has 3 rows and Table B has 4 rows = 12 rows 
-- Use for needing to generate all possible combinations 


-- EXAMPLE for Cross JOIN 
CREATE TABLE DepartmentA ( 
    DeptID INT PRIMARY KEY, 
    DeptName VARCHAR(50) 
    );

INSERT INTO DepartmentA( DeptID, DeptName)VALUES 
(1, 'HR'), 
(2, 'Finance'), 
(3, 'IT');

CREATE TABLE DepartmentB ( 
    DeptID INT PRIMARY KEY, 
    DeptName VARCHAR(50)
    );

INSERT INTO DepartmentB(DeptID, DeptName)VALUES 
(4, 'Marketing'), 
(5, 'Sales'), 
(6, 'Support'); 


SELECT A.DeptName AS DepartmentA, 
       B.DeptName AS DepartmentB 

FROM DepartmentA A CROSS JOIN DepartmentB B;


-- Full Outer JOIN -- Combines Left and Right Join 
-- Returns all rows from both tables matching where possible

-- If not match, fills missing columns with NULL 
-- Use for when you need a complete view of both tables, including unmatched rows

CREAT



Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: