<legend id='LDnXd'><style id='LDnXd'><dir id='LDnXd'><q id='LDnXd'></q></dir></style></legend>

      1. <small id='LDnXd'></small><noframes id='LDnXd'>

          <bdo id='LDnXd'></bdo><ul id='LDnXd'></ul>
        <i id='LDnXd'><tr id='LDnXd'><dt id='LDnXd'><q id='LDnXd'><span id='LDnXd'><b id='LDnXd'><form id='LDnXd'><ins id='LDnXd'></ins><ul id='LDnXd'></ul><sub id='LDnXd'></sub></form><legend id='LDnXd'></legend><bdo id='LDnXd'><pre id='LDnXd'><center id='LDnXd'></center></pre></bdo></b><th id='LDnXd'></th></span></q></dt></tr></i><div id='LDnXd'><tfoot id='LDnXd'></tfoot><dl id='LDnXd'><fieldset id='LDnXd'></fieldset></dl></div>
      2. <tfoot id='LDnXd'></tfoot>

        在 MySQL 中使用 Join 删除

        时间:2023-08-19

      3. <small id='PkZGa'></small><noframes id='PkZGa'>

            <tbody id='PkZGa'></tbody>
          • <bdo id='PkZGa'></bdo><ul id='PkZGa'></ul>
            <i id='PkZGa'><tr id='PkZGa'><dt id='PkZGa'><q id='PkZGa'><span id='PkZGa'><b id='PkZGa'><form id='PkZGa'><ins id='PkZGa'></ins><ul id='PkZGa'></ul><sub id='PkZGa'></sub></form><legend id='PkZGa'></legend><bdo id='PkZGa'><pre id='PkZGa'><center id='PkZGa'></center></pre></bdo></b><th id='PkZGa'></th></span></q></dt></tr></i><div id='PkZGa'><tfoot id='PkZGa'></tfoot><dl id='PkZGa'><fieldset id='PkZGa'></fieldset></dl></div>
            • <tfoot id='PkZGa'></tfoot>

                <legend id='PkZGa'><style id='PkZGa'><dir id='PkZGa'><q id='PkZGa'></q></dir></style></legend>

                  本文介绍了在 MySQL 中使用 Join 删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  这是创建我的表的脚本:

                  Here is the script to create my tables:

                  CREATE TABLE clients (
                     client_i INT(11),
                     PRIMARY KEY (client_id)
                  );
                  CREATE TABLE projects (
                     project_id INT(11) UNSIGNED,
                     client_id INT(11) UNSIGNED,
                     PRIMARY KEY (project_id)
                  );
                  CREATE TABLE posts (
                     post_id INT(11) UNSIGNED,
                     project_id INT(11) UNSIGNED,
                     PRIMARY KEY (post_id)
                  );
                  

                  在我的 PHP 代码中,删除客户端时,我想删除所有项目帖子:

                  In my PHP code, when deleting a client, I want to delete all projects posts:

                  DELETE 
                  FROM posts
                  INNER JOIN projects ON projects.project_id = posts.project_id
                  WHERE projects.client_id = :client_id;
                  

                  posts 表没有外键 client_id,只有 project_id.我想删除项目中传递了 client_id 的帖子.

                  The posts table does not have a foreign key client_id, only project_id. I want to delete the posts in projects that have the passed client_id.

                  这现在不起作用,因为没有帖子被删除.

                  This is not working right now because no posts are deleted.

                  推荐答案

                  您只需要指定要从 posts 表中删除条目:

                  You just need to specify that you want to delete the entries from the posts table:

                  DELETE posts
                  FROM posts
                  INNER JOIN projects ON projects.project_id = posts.project_id
                  WHERE projects.client_id = :client_id
                  

                  有关更多信息,您可以查看此替代答案

                  For more information you can see this alternative answer

                  这篇关于在 MySQL 中使用 Join 删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:MySQL查询GROUP BY日/月/年 下一篇:MYSQL 使用 LOAD DATA INFILE 从 csv 导入数据

                  相关文章

                  最新文章

                  <i id='qOI6M'><tr id='qOI6M'><dt id='qOI6M'><q id='qOI6M'><span id='qOI6M'><b id='qOI6M'><form id='qOI6M'><ins id='qOI6M'></ins><ul id='qOI6M'></ul><sub id='qOI6M'></sub></form><legend id='qOI6M'></legend><bdo id='qOI6M'><pre id='qOI6M'><center id='qOI6M'></center></pre></bdo></b><th id='qOI6M'></th></span></q></dt></tr></i><div id='qOI6M'><tfoot id='qOI6M'></tfoot><dl id='qOI6M'><fieldset id='qOI6M'></fieldset></dl></div>
                1. <legend id='qOI6M'><style id='qOI6M'><dir id='qOI6M'><q id='qOI6M'></q></dir></style></legend>
                    • <bdo id='qOI6M'></bdo><ul id='qOI6M'></ul>
                    <tfoot id='qOI6M'></tfoot>

                    1. <small id='qOI6M'></small><noframes id='qOI6M'>