I have 100 rows that I need deleted, based on a PersonId
and CarModel
. Some PersonId
could have multiple CarModel
s, so if I use
DELETE FROM myTable
WHERE PersonId IN (
101,
102,
103,
104
)
AND CarModel IN (
'Honda Accord',
'Ford Explorer',
'Other car model',
'Last car model'
)
Then that will have false positives of delete 101, 'Ford Explorer' which I don't want. only 101, 'Honda Accord' and 102, 'Ford Explorer'
I could format it as
DELETE FROM myTable
WHERE
(PersonId = 101 AND CarModel = 'Honda) Accord'
OR (PersonId = 102 AND CarModel = 'Ford Explorer')
OR (PersonId = 103 AND CarModel = 'model 1')
OR ( PersonId = 104 AND CarModel = 'model 2')
But that's kinda ugly. Is there cleaner syntax? I can't find a multi-column where clause for big lists