SELECT
	r.RegulationId,
     r.RegulationRegulationTypeId,
     r.RegulationConditionId,
     r.RegulationOrganizationId,
     r.RegulationName,
     r.RegulationCreateBy,
     r.RegulationCreateDate,
	e.EmployeeOrganizationId
FROM
	[Transaction].[Regulations] AS r
	INNER JOIN
	[Master].[Users] AS u
		ON r.RegulationCreateBy = u.UserId
	INNER JOIN
	[Master].[Employees] AS e
		ON u.UserEmployeeId = e.EmployeeId
WHERE
	e.EmployeeOrganizationId <> r.RegulationOrganizationId


--UPDATE
--	r
--SET
--	r.RegulationOrganizationId = e.EmployeeOrganizationId
--FROM
--	[Transaction].[Regulations] AS r
--	INNER JOIN
--	[Master].[Users] AS u
--		ON r.RegulationCreateBy = u.UserId
--	INNER JOIN
--	[Master].[Employees] AS e
--		ON u.UserEmployeeId = e.EmployeeId
--WHERE
--	e.EmployeeOrganizationId <> r.RegulationOrganizationId


