Delete rows from several tables at the same time with MySQL

0

I am trying to delete several rows of several tables at the same time using this statement in mysql

DELETE fhi, ave, car, pen FROM fhi INNER JOIN ave INNER JOIN car INNER JOIN pen
                WHERE fhi.id = 1
                AND fhi.id2 = 4
                AND ave.id = 1
                AND ave.id2 = 4
                AND car.id = 1
                AND car.id2 = 4
                AND pen.id= 4;

When inserting this statement, it does not give me an error but it does not delete anything, this leaves: 0 rows affected. (The query took 0.0000 seconds.). I am using phpMyAdmin 4.7.4

    
asked by Antonio Méndez 20.09.2018 в 01:42
source

1 answer

0

The statement does not generate Result because the join has not been initialized, so to speak.

You must relate them using (ON) It should be like this.

DELETE fhi, bird, car, pen

FROM fhi

INNER JOIN ave ON ave.id = 1 AND ave.id2 = 4

INNER JOIN car ON car.id = 1 AND car.id2 = 4

INNER JOIN pen ON pen.id = 4

WHERE

fhi.id = 1 AND fhi.id2 = 4;

    
answered by 20.09.2018 / 02:26
source