I was trying to full join to tables as the code below,
x
SELECT C.cust_name,O.ord_num
FROM customers C
FULL JOIN orders O
ON C.cust_code = O.cust_code;
but this code is not working.Is anyone can solve this?
Advertisement
Answer
You can use:
SELECT C.cust_name, O.ord_num
FROM customers C
LEFT JOIN orders O
ON C.cust_code = O.cust_code
UNION ALL
SELECT null, O.ord_num
FROM orders O
LEFT JOIN customers C
ON C.cust_code = O.cust_code
WHERE C.cust_code IS NULL;