2

I need to update table CSPM.TRACT with the values of CFPL.SVALUE where CSPM.ID = PM.PMPERMITID AND CSPM.TRACT IS NULL.

Here are the joins in place between the three tables: PM LEFT OUTER JOIN CFPL INNER JOIN CSPM ON CFPL.GCUSTOMFIELDPICKLISTITEM = CSPM.TRACTS ON PM.PMPERMITID = CSPM.ID

1
  • Can you provide more information, it looks like you may be leaving things out. Commented Dec 31, 2019 at 20:02

2 Answers 2

2

Try this -

 UPDATE CSPM SET CSPM.TRACT = COALESCE (CSPM.TRACT, CFPL.SVALUE) FROM CSPM JOIN PM ON CSPM.ID = PM.PMPERMITID LEFT OUTER JOIN CFPL ON CFPL.GCUSTOMFIELDPICKLISTITEM = CSPM.TRACTS 
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry Bharati, I'm new to this board and didn't know to do that. Thanks again!
1

When dealing with outer joins sometimes the where clause restricts the normal outer join. Fortunately with a coalesce you can get around this complication and have a relatively straight-forward query:

update CSPM set TRACT = coalesce(CSPM.TRACT, CFPL.SVALUE) from CSPM join PM on CSPM.ID = PM.PMPERMITD left join CFPL on CFPL.GCUSTOMFIELDPICKLISTITEM = CSPM.TRACTS 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.