I have tables all with the same columns and have divided them up this way to keep them small.
e.g. Tables - cpus, gfxcards, monitors. Columns - titleId, categoryId, name.
What I'm trying to do is similar to this
SELECT * FROM cpus
UNION
SELECT * FROM gfxcards;
DELETE FROM test WHERE (titleId,categoryId) IN ((2,0));
Is there a way to do this or do I have to use transactions to avoid multiple delete queries?
Ah, nevermind. I worked out the query I was looking for. e.g. To delete CPUs with IDs 4,7 from 'cpus' table and monitors with IDs 105,106 from 'monitors' table, the following single query works.
DELETE
c, m FROM cpus c, monitors m
WHERE
(c.titleId,c.categoryId) IN ( (4,0), (7,0) )
AND
(m.titleId,m.categoryId) IN ( (105,3), (106,3) );
But thanks for the replies =)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With