mardi 30 juillet 2019

sql - if something then do this if nothing do nothing

I have a column with many nulls in table 1, but now and then there is a value. If there is a value, i want to go to table 2 and take the the corresponding value from there. This should create an extra column called user_original

CASE
    WHEN table1.user_changed IS NOT NULL THEN table2.user_original ELSE -- do nothing  
    END as user_original

I basically want to replace

is nothing

Is this correct ? hw can this be done? is there a better way?

Aucun commentaire:

Enregistrer un commentaire