{"id":6503,"date":"2024-11-14T11:03:15","date_gmt":"2024-11-14T03:03:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6503\/"},"modified":"2024-11-14T11:03:15","modified_gmt":"2024-11-14T03:03:15","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e6%80%8e%e4%b9%88%e6%9d%a1%e4%bb%b6%e5%88%a0%e9%99%a4%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6503\/","title":{"rendered":"mysql\u6570\u636e\u5e93\u600e\u4e48\u6761\u4ef6\u5220\u9664\u6570\u636e"},"content":{"rendered":"<blockquote><p>\n  \u5728 mysql \u6570\u636e\u5e93\u4e2d\uff0c\u4f7f\u7528 delete \u8bed\u53e5\u6267\u884c\u6761\u4ef6\u5220\u9664\u65f6\uff0c\u8bed\u6cd5\u4e3a\uff1adelete from table_name where condition; \u5176\u4e2d\uff0ctable_name \u4e3a\u8868\u540d\uff0ccondition \u6307\u5b9a\u8981\u5220\u9664\u884c\u7684\u6761\u4ef6\u3002\u4f8b\u5982\uff0c\u8981\u5220\u9664\u5e74\u9f84\u5927\u4e8e 30 \u5c81\u7684\u6240\u6709\u5ba2\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528 delete from customers where age &gt; 30; \u6ce8\u610f\uff1a\u6761\u4ef6\u4e2d\u53ef\u5305\u542b\u591a\u4e2a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u3002\u5efa\u8bae\u5728\u6267\u884c\u6761\u4ef6\u5220\u9664\u524d\u5148\u4f7f\u7528 select \u8bed\u53e5\u68c0\u67e5\u8981\u5220\u9664\u7684\u6570\u636e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080517463914323.jpg\" class=\"aligncenter\" title=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u6761\u4ef6\u5220\u9664\u6570\u636e\u63d2\u56fe\" alt=\"mysql\u6570\u636e\u5e93\u600e\u4e48\u6761\u4ef6\u5220\u9664\u6570\u636e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 MySQL \u6570\u636e\u5e93\u6267\u884c\u6761\u4ef6\u5220\u9664<\/strong><\/p>\n<p>\u5728 MySQL \u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 DELETE \u8bed\u53e5\u5220\u9664\u6570\u636e\u3002\u8981\u6267\u884c\u6761\u4ef6\u5220\u9664\uff0c\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u6ee1\u8db3\u5220\u9664\u6761\u4ef6\u7684\u884c\u3002<\/p>\n<p><strong>DELETE \u8bed\u53e5\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>DELETE FROM table_name\nWHERE condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5176\u4e2d\uff1a<\/strong><\/p>\n<ul>\n<li>table_name\uff1a\u8981\u4ece\u4e2d\u5220\u9664\u6570\u636e\u7684\u8868\u540d\u3002<\/li>\n<li>condition\uff1a\u6307\u5b9a\u8981\u5220\u9664\u7684\u884c\uff08\u53ef\u9009\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u5f20\u540d\u4e3a &#8220;customers&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u6570\u636e\uff1a<\/p>\n<pre>+----+------------+--------+\n| id | name       | age    |\n+----+------------+--------+\n| 1  | John Doe   | 30     |\n| 2  | Jane Smith | 25     |\n| 3  | Bill Jones | 40     |\n+----+------------+--------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u5220\u9664\u5e74\u9f84\u5927\u4e8e 30 \u5c81\u7684\u6240\u6709\u5ba2\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b DELETE \u8bed\u53e5\uff1a<\/p>\n<pre>DELETE FROM customers\nWHERE age &gt; 30;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6267\u884c\u8be5\u8bed\u53e5\u540e\uff0c\u8868\u4e2d\u7684\u6570\u636e\u5c06\u53d8\u4e3a\uff1a<\/p>\n<pre>+----+------------+--------+\n| id | name       | age    |\n+----+------------+--------+\n| 2  | Jane Smith | 25     |\n+----+------------+--------+<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u6761\u4ef6\u4e2d\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff0c\u5982 &gt;\u3001<\/li>\n<li>\u8fd8\u53ef\u4ee5\u4f7f\u7528\u903b\u8f91\u8fd0\u7b97\u7b26\uff08\u5982 AND\u3001OR\uff09\u5c06\u591a\u4e2a\u6761\u4ef6\u7ec4\u5408\u5728\u4e00\u8d77\u3002<\/li>\n<li>\u5728\u6267\u884c\u6761\u4ef6\u5220\u9664\u4e4b\u524d\uff0c\u5efa\u8bae\u5148\u4f7f\u7528 SELECT \u8bed\u53e5\u68c0\u67e5\u8981\u5220\u9664\u7684\u6570\u636e\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6570\u636e\u5e93\u600e\u4e48\u6761\u4ef6\u5220\u9664\u6570\u636e\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 mysql \u6570\u636e\u5e93\u4e2d\uff0c\u4f7f\u7528 delete \u8bed\u53e5\u6267\u884c\u6761\u4ef6\u5220\u9664\u65f6\uff0c\u8bed\u6cd5\u4e3a\uff1adelete from table_name where condition; \u5176\u4e2d\uff0ctable_name \u4e3a\u8868\u540d\uff0ccondition \u6307\u5b9a\u8981\u5220\u9664\u884c\u7684\u6761\u4ef6\u3002\u4f8b\u5982\uff0c\u8981\u5220\u9664\u5e74\u9f84\u5927\u4e8e 30 \u5c81\u7684\u6240\u6709\u5ba2\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528 delete from customers where age &gt; 30; \u6ce8\u610f\uff1a\u6761\u4ef6\u4e2d\u53ef\u5305\u542b\u591a\u4e2a\u6bd4\u8f83\u8fd0\u7b97\u7b26\u548c\u903b\u8f91\u8fd0\u7b97\u7b26\u3002\u5efa\u8bae\u5728\u6267\u884c\u6761\u4ef6\u5220\u9664\u524d\u5148\u4f7f\u7528 select \u8bed\u53e5\u68c0\u67e5\u8981\u5220\u9664\u7684\u6570\u636e\u3002 \u4f7f\u7528 MySQL \u6570\u636e\u5e93\u6267\u884c\u6761\u4ef6\u5220\u9664 \u5728 MySQL \u6570\u636e\u5e93\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 DELETE \u8bed\u53e5\u5220\u9664\u6570\u636e\u3002\u8981\u6267\u884c\u6761\u4ef6\u5220\u9664\uff0c\u9700\u8981\u6307\u5b9a\u4e00\u4e2a\u6216\u591a\u4e2a\u6ee1\u8db3\u5220\u9664\u6761\u4ef6\u7684\u884c\u3002 DELETE \u8bed\u53e5\u8bed\u6cd5\uff1a DELETE FROM table_name WHERE condition; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a table_name\uff1a\u8981\u4ece\u4e2d\u5220\u9664\u6570\u636e\u7684\u8868\u540d\u3002 condition\uff1a\u6307\u5b9a\u8981\u5220\u9664\u7684\u884c\uff08\u53ef\u9009\uff09\u3002 \u793a\u4f8b\uff1a \u5047\u8bbe\u6211\u4eec\u6709\u4e00\u5f20\u540d\u4e3a &#8220;customers&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4ee5\u4e0b\u6570\u636e\uff1a +&#8212;-+&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;&#8211;+ | id | name | age | [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6503","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6503"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6503\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}