我想使用SQL和PHP删除一个特定的行、事件和外键eventlocation。我试图使用内部连接函数,但这给了我一个错误。有什么想法吗?

DELETE FROM Events, EventLocation JOIN ON EventLocation.EventLocationID = Events.EventLocationID WHERE EventID = '".$_POST["id"]."' AND EventLocationID = '".$_POST["id"]."'

最佳答案

使用内部连接

DELETE Events, EventLocation FROM Events INNER JOIN EventLocation WHERE Events.EventID=EventLocation.EventID

07-27 21:31