简体   繁体   English

这个查询怎么了

[英]what's wrong with this query

$deleteUser = $_POST['userId'];

$query =    "DELETE FROM users AS USERS
           LEFT JOIN posts AS POSTS
           ON USERS.id = POSTS.postAuthor
           WHERE USERS.id = '$deleteUser' AND POSTS.postAuthor = '$deleteUser'";

I'm trying to remove the user and any posts they may have created. 我正在尝试删除用户以及他们可能创建的所有帖子。 what am i missing? 我想念什么?

specify the table or the alias where the DELETE exucutes 指定DELETE执行的表或别名

DELETE USERS FROM users AS USERS
       LEFT JOIN posts AS POSTS
       ON USERS.id = POSTS.postAuthor
WHERE USERS.id = '$deleteUser' AND POSTS.postAuthor = '$deleteUser'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM