'Delete query error: Every derived table must have its own alias
I have to tables A and B
Structure of A:
ID | B_ID | data1 | data2
Where B_ID is the primary key from table B
Structure of B:
ID | datax | data3
And I'm trying to delete from An every row where B_ID not exists in B table. The query I'm trying to execute is
DELETE A FROM A JOIN
(
SELECT * FROM `produs` A
left join B b on B.ID=A.B_ID
where B.ID is null
)
Select query is working fine but when I execute the above statement I get this message:
Every derived table must have its own alias
Note: I want delete query to work with JOIN not IN.
Solution 1:[1]
You would need to do like
DELETE A FROM A JOIN
(
SELECT * FROM `produs` A
left join B b on B.ID=A.B_ID
where B.ID is null
) analiasname;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Avinash Babu |
