Click here to Skip to main content
14,427,367 members
Rate this:
Please Sign up or sign in to vote.
create table #temp
(
partid     int,
maskid     int,
chemicalid int,
status  nvarchar(50)
)
insert into #temp
values
(100,1000,901)
(700,1700,909)
(400,1500,920)
Parts   
pk       
PartId    maskId
100       1000
200       1000
400       1500
600       1700
700       1700

Chemical Master Table
   PK                          fk
Chemicalmasterid  ChemicalId  PartId
  1                901         100
  2                902         200
  4                920         400
  6                909         600
  7                909         700




I need to write query do

update status='conflict chemical id' where
another parts related to same mask on temp table #temp have different checmicalid

for explain

#temp table have part 100 for masked 1000 and checmicalId 901
I will search on database

Are mask number 1000 have related parts ON Table parts have same maskId ?

yes it have

what other parts have same maskId ?

200 have maskid 1000

Are these parts as 200 have same chemicalid as exist on temp table #temp for same maskId ?

No then status will be 'conflict checmical id '

status conflict because maskId 1000 have chemicalId 901 on temp table #temp but on table parts
related parts have same maskId have different chemicalId as 902

What I have tried:

finalResult
100 1000 901  conflict chemicalid
700 1700 909
400 1500 920
Posted
Updated 8-Jan-20 14:47pm
v2
Comments
Maciej Los 9-Jan-20 2:28am
   
Stop asking the same question several times!
ahmed_sa 9-Jan-20 2:50am
   
thank you for reply this is not same question
if i ask more question on one question it will difficult for understand
ZurdoDev 9-Jan-20 7:48am
   
Reply to the comment so that the user is notified.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,103
Richard MacCutchan 1,804
phil.o 1,270
Patrice T 1,187
MadMyche 1,100



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100