{"id":44683,"date":"2024-12-01T17:52:32","date_gmt":"2024-12-01T09:52:32","guid":{"rendered":"https:\/\/fwq.ai\/blog\/44683\/"},"modified":"2024-12-01T17:52:32","modified_gmt":"2024-12-01T09:52:32","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mysql-%e6%89%b9%e9%87%8f%e4%bf%ae%e6%94%b9%e8%a1%a8%e4%b8%ad%e6%9f%90%e4%b8%80%e5%88%97%e7%9a%84%e5%80%bc%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/44683\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241031\/17303355466722d33a4162c.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6279\u91cf\u4fee\u6539 mysql \u6570\u636e<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong>\u5982\u4f55\u5728 mysql \u8868\u4e2d\u6279\u91cf\u4fee\u6539\u67d0\u4e00\u5217\u7684\u503c\uff1f<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<p>mysql \u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684 update \u8bed\u53e5\uff0c\u7528\u4e8e\u6279\u91cf\u4fee\u6539\u8868\u4e2d\u7684\u6570\u636e\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>update \u8868\u540d\nset \u5217\u540d = \u65b0\u503c\nwhere \u6761\u4ef6<\/pre>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u8981\u5c06\u8868 &#8220;users&#8221; \u4e2d\u5217\u540d &#8220;status&#8221; \u4e3a &#8216;a&#8217; \u7684\u6240\u6709\u503c\u4fee\u6539\u4e3a &#8216;b&#8217;\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>UPDATE users\nSET status = 'b'\nWHERE status = 'a';<\/pre>\n<p><strong>\u6267\u884c\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u9996\u5148\u5728 mysql \u5ba2\u6237\u7aef\u4e2d\u627e\u5230\u8981\u4fee\u6539\u7684\u8868\u3002<\/li>\n<li>\u4f7f\u7528 update \u8bed\u53e5\u6307\u5b9a\u8868\u540d\u3001\u8981\u4fee\u6539\u7684\u5217\u4ee5\u53ca\u65b0\u503c\u3002<\/li>\n<li>\u4f7f\u7528 where \u5b50\u53e5\u6307\u5b9a\u8981\u4fee\u6539\u7684\u884c\uff08\u5373\uff0c\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\uff09\u3002<\/li>\n<li>\u6267\u884c\u8bed\u53e5\uff0c\u6240\u6709\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u5c06\u88ab\u66f4\u65b0\u3002<\/li>\n<\/ol>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u65b0\u503c\u4e0e\u5217\u7684\u6570\u636e\u7c7b\u578b\u517c\u5bb9\u3002<\/li>\n<li>\u5728\u6267\u884c update \u8bed\u53e5\u4e4b\u524d\uff0c\u8bf7\u5907\u4efd\u8868\uff0c\u4ee5\u9632\u51fa\u73b0\u4efb\u4f55\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u672c\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f \u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01 \u6279\u91cf\u4fee\u6539 mysql \u6570\u636e \u95ee\u9898\uff1a\u5982\u4f55\u5728 mysql \u8868\u4e2d\u6279\u91cf\u4fee\u6539\u67d0\u4e00\u5217\u7684\u503c\uff1f \u89e3\u7b54\uff1a mysql \u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684 update \u8bed\u53e5\uff0c\u7528\u4e8e\u6279\u91cf\u4fee\u6539\u8868\u4e2d\u7684\u6570\u636e\u3002\u8bed\u6cd5\u5982\u4e0b\uff1a update \u8868\u540d set \u5217\u540d = \u65b0\u503c where \u6761\u4ef6 \u793a\u4f8b\uff1a \u8981\u5c06\u8868 &#8220;users&#8221; \u4e2d\u5217\u540d &#8220;status&#8221; \u4e3a &#8216;a&#8217; \u7684\u6240\u6709\u503c\u4fee\u6539\u4e3a &#8216;b&#8217;\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a UPDATE users SET status = &#8216;b&#8217; WHERE status = &#8216;a&#8217;; \u6267\u884c\u6b65\u9aa4\uff1a \u9996\u5148\u5728 mysql \u5ba2\u6237\u7aef\u4e2d\u627e\u5230\u8981\u4fee\u6539\u7684\u8868\u3002 \u4f7f\u7528 update \u8bed\u53e5\u6307\u5b9a\u8868\u540d\u3001\u8981\u4fee\u6539\u7684\u5217\u4ee5\u53ca\u65b0\u503c\u3002 \u4f7f\u7528 where \u5b50\u53e5\u6307\u5b9a\u8981\u4fee\u6539\u7684\u884c\uff08\u5373\uff0c\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\uff09\u3002 \u6267\u884c\u8bed\u53e5\uff0c\u6240\u6709\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\u5c06\u88ab\u66f4\u65b0\u3002 \u6ce8\u610f\uff1a \u786e\u4fdd\u65b0\u503c\u4e0e\u5217\u7684\u6570\u636e\u7c7b\u578b\u517c\u5bb9\u3002 [&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-44683","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44683","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=44683"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44683\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=44683"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=44683"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=44683"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}