{"id":5267,"date":"2024-11-14T10:40:05","date_gmt":"2024-11-14T02:40:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5267\/"},"modified":"2024-11-14T10:40:05","modified_gmt":"2024-11-14T02:40:05","slug":"mysql%e8%b5%8b%e5%80%bc%e8%af%ad%e5%8f%a5%e6%80%8e%e4%b9%88%e8%bf%94%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5267\/","title":{"rendered":"mysql\u8d4b\u503c\u8bed\u53e5\u600e\u4e48\u8fd4\u56de"},"content":{"rendered":"<blockquote><p>\n  mysql \u4e2d\u7684\u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u5b83\u7528\u4e8e\u5c06\u4e00\u4e2a\u503c\u5206\u914d\u7ed9\u4e00\u4e2a\u53d8\u91cf\u3002\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 select \u67e5\u8be2\u6765\u83b7\u53d6\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052618012230289.jpg\" class=\"aligncenter\" title=\"mysql\u8d4b\u503c\u8bed\u53e5\u600e\u4e48\u8fd4\u56de\u63d2\u56fe\" alt=\"mysql\u8d4b\u503c\u8bed\u53e5\u600e\u4e48\u8fd4\u56de\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u8d4b\u503c\u8bed\u53e5\u5982\u4f55\u8fd4\u56de\uff1f<\/strong><\/p>\n<p>MySQL \u4e2d\u7684\u8d4b\u503c\u8bed\u53e5\u4e0d\u4f1a\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u5b83\u7528\u4e8e\u5c06\u4e00\u4e2a\u503c\u5206\u914d\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u800c\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u8f93\u51fa\u3002<\/p>\n<p>\u8d4b\u503c\u8bed\u53e5\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>SET var_name = value;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>var_name \u662f\u8981\u8d4b\u503c\u7684\u53d8\u91cf\u540d<\/li>\n<li>value \u662f\u8981\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c<\/li>\n<\/ul>\n<p><strong>\u4e3a\u4ec0\u4e48\u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff1f<\/strong><\/p>\n<p>\u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u662f\u56e0\u4e3a\u5b83\u4e0d\u662f\u4e00\u4e2a\u67e5\u8be2\u3002\u5b83\u53ea\u662f\u4e00\u4e2a\u7528\u4e8e\u4fee\u6539\u53d8\u91cf\u503c\u7684\u547d\u4ee4\u3002\u67e5\u8be2\u662f\u7528\u4e8e\u68c0\u7d22\u6570\u636e\u5e76\u4ea7\u751f\u8f93\u51fa\u7684\u547d\u4ee4\uff0c\u4f8b\u5982 SELECT \u67e5\u8be2\u3002<\/p>\n<p><strong>\u5982\u4f55\u83b7\u53d6\u8d4b\u503c\u8bed\u53e5\u7684\u7ed3\u679c\uff1f<\/strong><\/p>\n<p>\u867d\u7136\u8d4b\u503c\u8bed\u53e5\u672c\u8eab\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 SELECT \u67e5\u8be2\u6765\u83b7\u53d6\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c\u3002\u4ee5\u4e0b\u67e5\u8be2\u5c06\u663e\u793a @my_var \u53d8\u91cf\u7684\u503c\uff1a<\/p>\n<pre>SELECT @my_var;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u8d4b\u503c\u8bed\u53e5\u5e76\u5728\u540e\u7eed\u67e5\u8be2\u4e2d\u68c0\u7d22\u5206\u914d\u7684\u503c\uff1a<\/p>\n<pre>SET @my_var = 10;\n\nSELECT @my_var;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\uff1a<\/p>\n<pre>10<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8d4b\u503c\u8bed\u53e5\u600e\u4e48\u8fd4\u56de\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>mysql \u4e2d\u7684\u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u5b83\u7528\u4e8e\u5c06\u4e00\u4e2a\u503c\u5206\u914d\u7ed9\u4e00\u4e2a\u53d8\u91cf\u3002\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 select \u67e5\u8be2\u6765\u83b7\u53d6\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c\u3002 MySQL \u8d4b\u503c\u8bed\u53e5\u5982\u4f55\u8fd4\u56de\uff1f MySQL \u4e2d\u7684\u8d4b\u503c\u8bed\u53e5\u4e0d\u4f1a\u8fd4\u56de\u4efb\u4f55\u503c\u3002\u5b83\u7528\u4e8e\u5c06\u4e00\u4e2a\u503c\u5206\u914d\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u800c\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u8f93\u51fa\u3002 \u8d4b\u503c\u8bed\u53e5\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a SET var_name = value; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a var_name \u662f\u8981\u8d4b\u503c\u7684\u53d8\u91cf\u540d value \u662f\u8981\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c \u4e3a\u4ec0\u4e48\u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff1f \u8d4b\u503c\u8bed\u53e5\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\u662f\u56e0\u4e3a\u5b83\u4e0d\u662f\u4e00\u4e2a\u67e5\u8be2\u3002\u5b83\u53ea\u662f\u4e00\u4e2a\u7528\u4e8e\u4fee\u6539\u53d8\u91cf\u503c\u7684\u547d\u4ee4\u3002\u67e5\u8be2\u662f\u7528\u4e8e\u68c0\u7d22\u6570\u636e\u5e76\u4ea7\u751f\u8f93\u51fa\u7684\u547d\u4ee4\uff0c\u4f8b\u5982 SELECT \u67e5\u8be2\u3002 \u5982\u4f55\u83b7\u53d6\u8d4b\u503c\u8bed\u53e5\u7684\u7ed3\u679c\uff1f \u867d\u7136\u8d4b\u503c\u8bed\u53e5\u672c\u8eab\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 SELECT \u67e5\u8be2\u6765\u83b7\u53d6\u5206\u914d\u7ed9\u53d8\u91cf\u7684\u503c\u3002\u4ee5\u4e0b\u67e5\u8be2\u5c06\u663e\u793a @my_var \u53d8\u91cf\u7684\u503c\uff1a SELECT @my_var; \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b \u4ee5\u4e0b\u793a\u4f8b\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u8d4b\u503c\u8bed\u53e5\u5e76\u5728\u540e\u7eed\u67e5\u8be2\u4e2d\u68c0\u7d22\u5206\u914d\u7684\u503c\uff1a SET @my_var = 10; SELECT @my_var; \u767b\u5f55\u540e\u590d\u5236 \u8f93\u51fa\uff1a 10 \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u8d4b\u503c\u8bed\u53e5\u600e\u4e48\u8fd4\u56de\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5267","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5267","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=5267"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5267\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}