Alexander Dyagilev
Alexander Dyagilev

Reputation: 1425

SQLite DELETE several records with specified composite primary keys

My table contains 2 INTEGER primary key columns. I would like to delete several records with both of them specified. For example, (1,1) and (1,2). I've tried:

DELETE FROM my_table WHERE(primarykey1,primarykey2) IN ((1,1),(1,2))

incorrect syntax.

Upvotes: 1

Views: 762

Answers (2)

Alexander Dyagilev
Alexander Dyagilev

Reputation: 1425

DELETE FROM my_table WHERE primarykey1 = 1 AND primarykey2 IN (1,2)

Upvotes: 0

CL.
CL.

Reputation: 180200

Since SQLite version 3.15, you can use the following syntax:

DELETE FROM my_table WHERE (p1, pk2) IN (VALUES(1,1),(1,2));

Upvotes: 3

Related Questions