Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a query to delete some rows, whats wrong with it?

DELETE FROM table1, table2, table3
WHERE table1.id = table2.id
AND table2.id = table3.id
AND table1.id = 10

please help with query

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
297 views
Welcome To Ask or Share your Answers For Others

1 Answer

With this query it should work.

DELETE t1, t2, t3 FROM table1 t1
INNER JOIN table2 t2 ON t1.id = t2.id
INNER JOIN table3 t3 ON t2.id = t3.id
WHERE t1.id = 10

I tested it local with this schema: http://sqlfiddle.com/#!9/e5be4/9

Details you can find in the socd: https://dev.mysql.com/doc/refman/5.0/en/delete.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...