mardi 16 juin 2015

How do I delete DB rows for a range of partial keys?

I have a SQLite database table defined with 3 primary keys: Foo, Bar, and Charlie.

I also have a list of partial keys -- pairs of Foo, Bar.

I would like to delete all rows in the database table that match the partial key. I understand and intend that the partial key can match multiple rows, and want each partial match deleted in that case.

If I was using a list of just a single key, I could do something to the effect of:

"Delete from TABLENAME where FOO IN ('" + String.Join("','", fooList) + "')";

If I was using a single value and a partial key, I could do something to the effect of:

"Delete from TABLENAME where FOO = <foo_value> AND BAR = <bar_value>";

Is there some way to combine the IN syntax with a list of multiple partial-key entries?

Aucun commentaire:

Enregistrer un commentaire