Reputation: 15
I have 3 tables:
Table1: entitylink_test
parent_entity_id | child_entity_id
1 | 11
1 | 12
2 | 13
Table2: vm_host_id
vm_id | host_id
11 | 1
12 | 1
14 | 15
Table3: tagstorage
entity_id | tag_id
11 | 80
12 | 85
20 | 80
I want to delete from entitylink_test the rows where entitylink_test.child_entity_id = vm_host_id.vm_id and where tagstorage = 80
So far, I have tried
DELETE FROM entitylink_test
WHERE entitylink_test.child_entity_id = vm_host_id.vm_id
AND tagstorage.tag_id = 80;
And I've tried
DELETE entitylink_test
FROM entitylink_test INNER JOIN vm_host_id
ON entitylink_test.child_entity_id = vm_host_id.vm_id
INNER JOIN tagstorage
ON entitylink_test.child_entity_id = tagstorage.entity_id
WHERE tagstorage = 80;
However, I keep getting the error "Unknown column 'vm_host_id.vm_id' in 'where clause'" for the first code, and "Unknown column 'tagstorage' in 'where clause'" for the second. Any other suggestions for syntax?
Any help is appreciated,
Thank you!
Upvotes: 0
Views: 33
Reputation: 15150
I think you mean:
DELETE entitylink_test
FROM entitylink_test INNER JOIN vm_host_id
ON entitylink_test.child_entity_id = vm_host_id.vm_id
INNER JOIN tagstorage
ON entitylink_test.child_entity_id = tagstorage.entity_id
WHERE tagstorage.tag_id = 80;
You were referring to the table tagstorage
, a table doesn't have a value, so you should specify which attribute of the table should have value 80
.
Upvotes: 3