I have checked the answered questions. But, solutions are not working for me.
DELETE FROM TEST2
INNER JOIN TEST1 on TEST1.FIELD2 = TEST2.FIELD2
WHERE TEST1.FIELD1 = 22;
When i execute this query, i am getting the following error in phpmyadmin.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'INNER JOIN TEST1 on TEST1.FIELD2 = TEST2.FIELD2' at line 2
I am getting tired. I need help. Thanks in advance.
This should work:
DELETE T
FROM TEST2 T
INNER JOIN TEST1 on TEST1.FIELD2 = T.FIELD2
WHERE TEST1.FIELD1 = 22;
Sample Fiddle Demo
I think you can also do it with IN
:
DELETE FROM Test2
WHERE Field2 IN (
SELECT Field2
FROM Test1
WHERE Field1 = 22)
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