I have #TempMaster temp table have 3 fields
with optional values on 3 fields SourceGeneralTypeID AND StatusGeneralTypeID AND DailyLogId
meaning
may be SourceGeneralTypeID have values and other 2 fields not have value
may be StatusGeneralTypeID have values and other 2 fields not have value
may be DailyLogId have values and other 2 fields not have value
so my problem
How to write on statement after join on ? = ? where ?
problem how to write On ? = ? where ???????????????
and what i write on where
based on details above
details data
create table #TempMaster(
SourceGeneralTypeID int,
StatusGeneralTypeID int,
DailyLogId int
)
insert into #TempMaster
(SourceGeneralTypeID,StatusGeneralTypeID,DailyLogId)
values
(Null,10,20),
(2,Null,30),
(2,30,Null)
CREATE TABLE [MasterData](
[MasterDataID] [int] IDENTITY(1,1) NOT NULL,
[SourceGeneralTypeID] [int] NULL,
[StatusGeneralTypeID] [int] NULL,
[DailyLogId] [int] NULL,
CONSTRAINT [PK_MasterData] PRIMARY KEY CLUSTERED
(
[MasterDataID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
insert into [MasterData]
([SourceGeneralTypeID],[StatusGeneralTypeID],[DailyLogId])
values
(2,30,20),
(2,30,30),
(2,30,10)
What I have tried:
select M.MasterDataID,M.TrackingNumber,M.StatusDate
from #TempMaster tmp
INNER join [MasterData] M on ???=?????
where ??????