I have the following table:
and I want to delete records where c3 is null but only when another record with the same values for c1 and c2 already exists. In other words, remove only the row marked with red arrow. How can I do that?
I have the following table:
and I want to delete records where c3 is null but only when another record with the same values for c1 and c2 already exists. In other words, remove only the row marked with red arrow. How can I do that?
I'll write this as a select, so you don't copy paste and hose something accidentally- you can run it and check that it selects the rows you want to delete
Conversion to delete should just be a case of replacing the select * with a delete, but Do comment if it doesn't work out..
Edit remarks:
Used coalesce to demo how to make sure that a c2 value of null on row X is equivalent to another c2 value of null on row Y. It is important that the string you choose for 'value that will never appear in the table' is identical in both occurrences within the sql, and that it can never appear in the table, otherwise rows with nulls will match up with other rows that have actual values