{"id":7063,"date":"2024-11-14T08:00:08","date_gmt":"2024-11-14T00:00:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7063\/"},"modified":"2024-11-14T08:00:08","modified_gmt":"2024-11-14T00:00:08","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%e6%95%b0%e6%8d%ae%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7063\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u6570\u636e\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173037209381814.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u6570\u636e\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u6570\u636e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528  \u6279\u91cf\u4fee\u6539\u6570\u636e<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\uff0c\u5982\u679c\u60a8\u9700\u8981\u6279\u91cf\u4fee\u6539\u8868\u4e2d\u7684\u4e00\u5217\u6570\u636e\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528 update \u8bed\u53e5\u3002<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u5047\u8bbe\u60a8\u6709\u4e00\u4e2a\u540d\u4e3a users \u7684\u8868\uff0c\u5176\u4e2d\u6709\u4e00\u5217\u540d\u4e3a status\u3002\u8981\u5c06\u6240\u6709 status \u5217\u503c\u4e3a a \u7684\u884c\u4fee\u6539\u4e3a b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>update users\nset status = 'b'\nwhere status = 'a';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8be5\u67e5\u8be2\u5c06\u66f4\u65b0 users \u8868\u4e2d\u6240\u6709 status \u5217\u503c\u4e3a a \u7684\u884c\uff0c\u5c06\u5b83\u4eec\u4fee\u6539\u4e3a b\u3002<\/p>\n<p><strong>\u66f4\u8be6\u7ec6\u7684\u8bed\u6cd5<\/strong><\/p>\n<p>update \u8bed\u53e5\u7684\u5b8c\u6574\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>UPDATE &lt;table_name&gt;\nSET &lt;column_name&gt; = &lt;new_value&gt;\n[WHERE &lt;condition&gt;];<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li> \u662f\u60a8\u8981\u4fee\u6539\u7684\u8868\u7684\u540d\u79f0\u3002 <\/li>\n<li> \u662f\u60a8\u8981\u4fee\u6539\u7684\u5217\u7684\u540d\u79f0\u3002 <\/li>\n<li> \u662f\u60a8\u8981\u5c06\u5217\u503c\u4fee\u6539\u4e3a\u7684\u65b0\u503c\u3002 <\/li>\n<li>[where ] \u662f\u53ef\u9009\u9879\uff0c\u7528\u4e8e\u6307\u5b9a\u7b5b\u9009\u8981\u4fee\u6539\u7684\u884c\u3002 <\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MySQL \u6279\u91cf\u4fee\u6539\u6570\u636e\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>\u5982\u4f55\u4f7f\u7528 \u6279\u91cf\u4fee\u6539\u6570\u636e \u5728 mysql \u4e2d\uff0c\u5982\u679c\u60a8\u9700\u8981\u6279\u91cf\u4fee\u6539\u8868\u4e2d\u7684\u4e00\u5217\u6570\u636e\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528 update \u8bed\u53e5\u3002 \u793a\u4f8b \u5047\u8bbe\u60a8\u6709\u4e00\u4e2a\u540d\u4e3a users \u7684\u8868\uff0c\u5176\u4e2d\u6709\u4e00\u5217\u540d\u4e3a status\u3002\u8981\u5c06\u6240\u6709 status \u5217\u503c\u4e3a a \u7684\u884c\u4fee\u6539\u4e3a b\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8be2\uff1a update users set status = &#8216;b&#8217; where status = &#8216;a&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u8be5\u67e5\u8be2\u5c06\u66f4\u65b0 users \u8868\u4e2d\u6240\u6709 status \u5217\u503c\u4e3a a \u7684\u884c\uff0c\u5c06\u5b83\u4eec\u4fee\u6539\u4e3a b\u3002 \u66f4\u8be6\u7ec6\u7684\u8bed\u6cd5 update \u8bed\u53e5\u7684\u5b8c\u6574\u8bed\u6cd5\u5982\u4e0b\uff1a UPDATE &lt;table_name&gt; SET &lt;column_name&gt; = &lt;new_value&gt; [WHERE &lt;condition&gt;]; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a \u662f\u60a8\u8981\u4fee\u6539\u7684\u8868\u7684\u540d\u79f0\u3002 \u662f\u60a8\u8981\u4fee\u6539\u7684\u5217\u7684\u540d\u79f0\u3002 \u662f\u60a8\u8981\u5c06\u5217\u503c\u4fee\u6539\u4e3a\u7684\u65b0\u503c\u3002 [where ] \u662f\u53ef\u9009\u9879\uff0c\u7528\u4e8e\u6307\u5b9a\u7b5b\u9009\u8981\u4fee\u6539\u7684\u884c\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-7063","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7063","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=7063"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7063\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7063"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7063"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7063"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}