Delete query workaround in DB

33 Views Asked by At

At present the DB look like this:

item club
2    10
2    20
2    30
3    30
3    40
3    60
4    30
4    40
4    60

I want to delete club 10 of item 2 and club (30,40) of item 3.

For that I am using this query

DELETE from allocation.testDelete where item in(2,3) and club in(10,30,40)

Now I know what wrong I am doing. I can delete first clubs for item 2 and then clubs for item 3 but can't we do it in a single query? I need to do in one transaction if possible. I am using JPA native for it. Which looks like delete from testDelete a where a.itemNbr in (:itemNbrs) and a.clubNbr in (:clubNbrs)

0

There are 0 best solutions below