0

Hi I need to update table with values in two columns based on a condition.

So I would basically need to do the following

update columns SecurityCode and Exchange in table FundPriceDetails where isincode = 'ES06139009N6' ,'GB00BYMT2284' ,'GB00BYNFF262')

I have the mappings of isin to Exchange in the query below.Need to add another column that will do isin to SecurityCode AS WELL

SELECT x.* FROM (SELECT 'ES06139009N6' AS lsin, 'MAD' AS col2 UNION ALL SELECT 'GB0002634946', 'LSE' UNION ALL SELECT 'SG1L01001701', 'SGX' ) x JOIN FundPriceDetails fpd ON fpd.lsin = x.lsin; 

How would update the table with these values

3 Answers 3

1
UPDATE FundPriceDetails SET FundPriceDetails .col1 = value, FundPriceDetails .col2 = value FROM FundPriceDetails INNER JOIN ( SELECT 'ES06139009N6' AS lsin, 'MAD' AS col2 UNION ALL SELECT 'GB0002634946', 'LSE' UNION ALL SELECT 'SG1L01001701', 'SGX' ) x ON FundPriceDetails.lsin = x.lsin; 
Sign up to request clarification or add additional context in comments.

Comments

1
UPDATE FundPriceDetails SET SecurityCode = value, Exchange = value WHERE isincode in('ES06139009N6' ,'GB00BYMT2284' ,'GB00BYNFF262') 

Comments

0

Your question is not clear, but I assume you meant:

with myData (lsin, col2) as ( SELECT 'ES06139009N6', 'MAD' UNION ALL SELECT 'GB0002634946', 'LSE' UNION ALL SELECT 'SG1L01001701', 'SGX' ) update FundPriceDetails set blahblahColumn = x.col2 from myData x where FundPriceDetails.lsin = x.lsin; 

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.