In SQL, is there a way to add rows which are not there (based on certain combinations).
All rows without values:
Col-a Col-a
Col-a Col-b
Col-a Col-c
...
The database:
Col-a Col-a Val-a
Col-a Col-b Val-b
Col-b Col-a Val-c
Col-b Col-b Val-d
...
Suppose a row with Col-a Col-c doesn't exist in db, I want to add Col-a, Col-c, 0
that is just insert the missing row with a zero value.
Example:
1,1,50
1,2,100
2,2,100
So here we are missing 2,1 hence add 2,1,0. I shall give a set [1,2] where values should be present for both.
Is there an easy way to do that?
Aucun commentaire:
Enregistrer un commentaire