Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
300 views
in Technique[技术] by (71.8m points)

mysql - Delete multiple rows error

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

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

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...