fb_pixel

How to delete an entry in the table, provided that the entry belongs to two id, and you only need to delete the entry with one id?

Development | Databases
Description
I had a blunted with such a seemingly simple question.
Please help.

There is a products_taxons table:
product_id | taxon_id
           |
5 | 693
5 | 694
5 | 7
5 | 200
5 | 305
...

I need, for all products with a taxon with id 694, to remove a taxon with id 693.

With this query, both 693 and 694 will be deleted.
DELETE FROM products_taxons WHERE taxon_id=693 AND taxon_id=694;

Can you please tell me how?
Attachments
No attachments
Info
Description
DELETE FROM products_taxons
WHERE taxon_id=693
AND product_id IN (
SELECT product_id
FROM products_taxons
WHERE taxon_id=694
); 

or

DELETE FROM products_taxons WHERE taxon_id=693 AND product_id IN(SELECT DISTINCT(product_id) FROM products_taxons taxon_id=694)

or

SELECT
a.*
FROM products_taxons a
JOIN products_taxons b ON a.product_id=b.product_id
where
b.taxon_id=694

if this query selects the correct strings - instead of SELECT use DELETE

on April 28th, 2020 (10:14 pm)
All coments
This job has not been commented yet.