{"id":7029,"date":"2024-11-14T08:21:03","date_gmt":"2024-11-14T00:21:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7029\/"},"modified":"2024-11-14T08:21:03","modified_gmt":"2024-11-14T00:21:03","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","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7029\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173033373310080.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  \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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u8868\u4e2d\u67d0\u4e00\u5217\u7684\u503c\uff1f\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>\u6279\u91cf\u4fee\u6539 \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 \u767b\u5f55\u540e\u590d\u5236 \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;; \u767b\u5f55\u540e\u590d\u5236 \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 \u5728\u6267\u884c update \u8bed\u53e5\u4e4b\u524d\uff0c\u8bf7\u5907\u4efd\u8868\uff0c\u4ee5\u9632\u51fa\u73b0\u4efb\u4f55\u95ee\u9898\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-7029","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7029","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=7029"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7029\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}