{"id":6516,"date":"2024-11-14T11:03:27","date_gmt":"2024-11-14T03:03:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6516\/"},"modified":"2024-11-14T11:03:27","modified_gmt":"2024-11-14T03:03:27","slug":"mysql%e6%80%8e%e4%b9%88%e5%88%a0%e9%99%a4%e8%a1%a8%e9%87%8c%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6516\/","title":{"rendered":"mysql\u600e\u4e48\u5220\u9664\u8868\u91cc\u6570\u636e\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u4f7f\u7528 delete \u8bed\u53e5\u4ece mysql \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff1a\u6307\u5b9a\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d (table_name)\u4f7f\u7528 where \u5b50\u53e5\u6307\u5b9a\u5220\u9664\u6761\u4ef6 (condition)\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/05\/2024080519393961999.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u5220\u9664\u8868\u91cc\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u5220\u9664\u8868\u91cc\u6570\u636e\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 MySQL \u4e2d\u5220\u9664\u8868\u4e2d\u7684\u8bb0\u5f55<\/strong><\/p>\n<p>\u8981\u4ece MySQL \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528 DELETE \u8bed\u53e5\u3002\u8be5\u8bed\u53e5\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>DELETE FROM table_name\nWHERE condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0ctable_name \u662f\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d\uff0ccondition \u662f\u7528\u4e8e\u6307\u5b9a\u8981\u5220\u9664\u54ea\u4e9b\u8bb0\u5f55\u7684\u6761\u4ef6\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5220\u9664\u8868 users \u4e2d\u6240\u6709\u540d\u4e3a &#8220;John&#8221; \u7684\u8bb0\u5f55\uff1a<\/p>\n<pre>DELETE FROM users\nWHERE name = \"John\";<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5176\u4ed6\u793a\u4f8b\uff1a<\/strong><\/p>\n<ul>\n<li>\u5220\u9664\u8868 orders \u4e2d\u6240\u6709\u603b\u91d1\u989d\u8d85\u8fc7 100 \u7684\u8bb0\u5f55\uff1a<\/li>\n<\/ul>\n<pre>DELETE FROM orders\nWHERE total_amount &gt; 100;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5220\u9664\u8868 products \u4e2d\u6240\u6709\u5df2\u552e\u7f44\u7684\u8bb0\u5f55\uff1a<\/li>\n<\/ul>\n<pre>DELETE FROM products\nWHERE stock_quantity = 0;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>DELETE \u8bed\u53e5\u4e0d\u53ef\u9006\uff0c\u56e0\u6b64\u5728\u6267\u884c\u5220\u9664\u64cd\u4f5c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u5907\u4efd\u6570\u636e\u3002<\/li>\n<li>\u5982\u679c\u4e0d\u4f7f\u7528 WHERE \u5b50\u53e5\uff0cDELETE \u8bed\u53e5\u5c06\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 LIMIT \u5b50\u53e5\u9650\u5236\u8981\u5220\u9664\u7684\u8bb0\u5f55\u6570\uff1a<\/li>\n<\/ul>\n<pre>DELETE FROM users\nWHERE name = \"John\"\nLIMIT 1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u5c06\u4ec5\u5220\u9664\u7b2c\u4e00\u4e2a\u540d\u4e3a &#8220;John&#8221; \u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5220\u9664\u8868\u91cc\u6570\u636e\u5e93\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>\u53ef\u4ee5\u4f7f\u7528 delete \u8bed\u53e5\u4ece mysql \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff1a\u6307\u5b9a\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d (table_name)\u4f7f\u7528 where \u5b50\u53e5\u6307\u5b9a\u5220\u9664\u6761\u4ef6 (condition) \u5982\u4f55\u5728 MySQL \u4e2d\u5220\u9664\u8868\u4e2d\u7684\u8bb0\u5f55 \u8981\u4ece MySQL \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff0c\u53ef\u4ee5\u4f7f\u7528 DELETE \u8bed\u53e5\u3002\u8be5\u8bed\u53e5\u7684\u57fa\u672c\u8bed\u6cd5\u5982\u4e0b\uff1a DELETE FROM table_name WHERE condition; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0ctable_name \u662f\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d\uff0ccondition \u662f\u7528\u4e8e\u6307\u5b9a\u8981\u5220\u9664\u54ea\u4e9b\u8bb0\u5f55\u7684\u6761\u4ef6\u3002 \u793a\u4f8b\uff1a \u5220\u9664\u8868 users \u4e2d\u6240\u6709\u540d\u4e3a &#8220;John&#8221; \u7684\u8bb0\u5f55\uff1a DELETE FROM users WHERE name = &#8220;John&#8221;; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4ed6\u793a\u4f8b\uff1a \u5220\u9664\u8868 orders \u4e2d\u6240\u6709\u603b\u91d1\u989d\u8d85\u8fc7 100 \u7684\u8bb0\u5f55\uff1a DELETE FROM orders WHERE total_amount &gt; 100; \u767b\u5f55\u540e\u590d\u5236 \u5220\u9664\u8868 [&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-6516","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6516","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=6516"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6516\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}