#The FULL JOIN keyword return rows when there is a match in one of the tables
synatax->SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
/////example////
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
FULL JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
#Syntax to execute FULL OUTER JOIN in SQL
FROM table1
FULL OUTER JOIN table2
ON table1.columnName = table2.columnName
WHERE condition;
SELECT Customers.customer_id, Customers.first_name, Orders.amount
FROM Customers
FULL OUTER JOIN Orders
ON Customers.customer_id = Orders.customer;
/****** Script for SelectTopNRows command from SSMS ******/
SELECT *,isnull(pvt1.id,0) FROM(
SELECT id,date,relay_type,line_number,machine_number
,process,TIMES,time_val
FROM
[OutputMonitoring].[dbo].[output_tbl]
UNPIVOT(
time_val FOR times
IN
([0000HR],
[0100HR])
) AS PV1
WHERE machine_number = 'CVR 9' and date = '2022-07-14'
)tb2
PIVOT (
max(time_val)
FOR TIMES IN ([0000HR],
[0100HR])
)pvt1
FULL JOIN target_tbl
on
target_tbl.relay_type = pvt1.relay_type
and target_tbl.line_no = pvt1.line_number
and target_tbl.machine_count = pvt1.machine_number
and target_tbl.process = pvt1.process
and target_tbl.Date = pvt1.date
WHERE pvt1.date = '2022-07-14'
FULL OUTER JOIN:
is used when retrieving data from
multiple tables and will return both
table records, matching and non-matching.