I'm trying to find the right syntax to delete records that are not in a comma separated row.
table A
| id | product_id | attribute_id |
|----|------------|--------------|
| 1 | 123 | 45 |
| 2 | 123 | 46 |
| 3 | 124 | 34 |
| 4 | 124 | 33 |
table B
| code | Axis |
|------|-------|
| 123 | 45,46 |
| 124 | 34 |
My goal is to remove all rows from table A where the attribute id is not in the table B axis value (in this example the row with id = 4).
I try to do a SELECT
before:
SELECT A.attribute_id, A.product_id
FROM tableA as A
LEFT JOIN (SELECT * FROM tableB) AS B
ON FIND_IN_SET(A.attribute_id, B.`axis`)
But without any luck.
How can I do this?