{"id":5224,"date":"2024-11-14T10:55:59","date_gmt":"2024-11-14T02:55:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5224\/"},"modified":"2024-11-14T10:55:59","modified_gmt":"2024-11-14T02:55:59","slug":"mysql%e5%87%bd%e6%95%b0%e6%80%8e%e4%b9%88%e8%b0%83%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5224\/","title":{"rendered":"mysql\u51fd\u6570\u600e\u4e48\u8c03\u7528"},"content":{"rendered":"<blockquote><p>\n  \u4f7f\u7528 mysql \u51fd\u6570\uff0c\u53ef\u4ee5\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u5e76\u8fd4\u56de\u7ed3\u679c\u3002\u8c03\u7528\u8bed\u6cd5\u4e3a\uff1afunction_name(argument1, argument2, &#8230;)\uff1b\u53ef\u4ee5\u4f20\u9012\u5e38\u91cf\u3001\u5217\u5f15\u7528\u6216\u5176\u4ed6\u51fd\u6570\u8f93\u51fa\u4f5c\u4e3a\u53c2\u6570\uff0c\u5e76\u83b7\u5f97\u5404\u79cd\u6570\u636e\u7c7b\u578b\u7684\u8fd4\u56de\u503c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/26\/2024052617003641418.jpg\" class=\"aligncenter\" title=\"mysql\u51fd\u6570\u600e\u4e48\u8c03\u7528\u63d2\u56fe\" alt=\"mysql\u51fd\u6570\u600e\u4e48\u8c03\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u8c03\u7528 MySQL \u51fd\u6570<\/strong><\/p>\n<p>\u5728 MySQL \u4e2d\uff0c\u51fd\u6570\u662f\u4e00\u79cd\u9884\u5b9a\u4e49\u7684\u4ee3\u7801\u5757\uff0c\u5b83\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u5e76\u8fd4\u56de\u7ed3\u679c\u3002\u51fd\u6570\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u67e5\u8be2\u548c\u64cd\u4f5c\u6570\u636e\u3002<\/p>\n<p><strong>\u8c03\u7528\u8bed\u6cd5<\/strong><\/p>\n<p>\u8981\u8c03\u7528\u4e00\u4e2a MySQL \u51fd\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>FUNCTION_NAME(argument1, argument2, ...)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>FUNCTION_NAME \u662f\u8981\u8c03\u7528\u7684\u51fd\u6570\u7684\u540d\u79f0\u3002<\/li>\n<li>argument1, argument2, &#8230; \u662f\u4f20\u9012\u7ed9\u51fd\u6570\u7684\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<p>\u4f8b\u5982\uff0c\u8981\u8c03\u7528 NOW() \u51fd\u6570\uff08\u5b83\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>NOW()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8981\u8c03\u7528 CONCAT() \u51fd\u6570\uff08\u5b83\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u5728\u4e00\u8d77\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a<\/p>\n<pre>CONCAT('Hello', ' World')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u53c2\u6570<\/strong><\/p>\n<p>\u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff0c\u53c2\u6570\u53ef\u4ee5\u662f\u5e38\u91cf\u3001\u5217\u5f15\u7528\u6216\u5176\u4ed6\u51fd\u6570\u7684\u8f93\u51fa\u3002\u4f8b\u5982\uff0cDATE_FORMAT() \u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u65e5\u671f\u503c\u548c\u4e00\u4e2a\u683c\u5f0f\u5b57\u7b26\u4e32\u4f5c\u4e3a\u53c2\u6570\uff1a<\/p>\n<pre>DATE_FORMAT('2023-03-08', '%Y-%m-%d')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8fd4\u56de\u503c<\/strong><\/p>\n<p>\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u503c\uff0c\u8be5\u503c\u53ef\u4ee5\u662f\u5404\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5982\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5e03\u5c14\u503c\u6216\u65e5\u671f\u3002\u8fd4\u56de\u7684\u503c\u53ef\u4ee5\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff0c\u4e0e\u5176\u4ed6\u51fd\u6570\u4e00\u8d77\u4f7f\u7528\uff0c\u6216\u7528\u4e8e\u63a7\u5236\u6267\u884c\u6d41\u7a0b\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u51fd\u6570\u540d\u79f0\u5fc5\u987b\u662f\u5927\u5199\u3002<\/li>\n<li>\u53c2\u6570\u5fc5\u987b\u4e0e\u51fd\u6570\u7684\u5b9a\u4e49\u76f8\u5339\u914d\u3002<\/li>\n<li>\u5982\u679c\u51fd\u6570\u4e0d\u63a5\u53d7\u53c2\u6570\uff0c\u5219\u7701\u7565\u62ec\u53f7\u3002<\/li>\n<li>\u51fd\u6570\u53ef\u4ee5\u5d4c\u5957\uff0c\u4f46\u5d4c\u5957\u7ea7\u522b\u4e0d\u5f97\u8d85\u8fc7 16 \u7ea7\u3002<\/li>\n<li>\u4f7f\u7528 DELIMITER \u8bed\u53e5\u53ef\u4ee5\u66f4\u6539\u51fd\u6570\u5b9a\u4e49\u7684\u5206\u9694\u7b26\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u51fd\u6570\u600e\u4e48\u8c03\u7528\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>\u4f7f\u7528 mysql \u51fd\u6570\uff0c\u53ef\u4ee5\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u5e76\u8fd4\u56de\u7ed3\u679c\u3002\u8c03\u7528\u8bed\u6cd5\u4e3a\uff1afunction_name(argument1, argument2, &#8230;)\uff1b\u53ef\u4ee5\u4f20\u9012\u5e38\u91cf\u3001\u5217\u5f15\u7528\u6216\u5176\u4ed6\u51fd\u6570\u8f93\u51fa\u4f5c\u4e3a\u53c2\u6570\uff0c\u5e76\u83b7\u5f97\u5404\u79cd\u6570\u636e\u7c7b\u578b\u7684\u8fd4\u56de\u503c\u3002 \u5982\u4f55\u8c03\u7528 MySQL \u51fd\u6570 \u5728 MySQL \u4e2d\uff0c\u51fd\u6570\u662f\u4e00\u79cd\u9884\u5b9a\u4e49\u7684\u4ee3\u7801\u5757\uff0c\u5b83\u6267\u884c\u7279\u5b9a\u4efb\u52a1\u5e76\u8fd4\u56de\u7ed3\u679c\u3002\u51fd\u6570\u53ef\u4ee5\u5927\u5927\u7b80\u5316\u67e5\u8be2\u548c\u64cd\u4f5c\u6570\u636e\u3002 \u8c03\u7528\u8bed\u6cd5 \u8981\u8c03\u7528\u4e00\u4e2a MySQL \u51fd\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a FUNCTION_NAME(argument1, argument2, &#8230;) \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a FUNCTION_NAME \u662f\u8981\u8c03\u7528\u7684\u51fd\u6570\u7684\u540d\u79f0\u3002 argument1, argument2, &#8230; \u662f\u4f20\u9012\u7ed9\u51fd\u6570\u7684\u53c2\u6570\u3002 \u793a\u4f8b \u4f8b\u5982\uff0c\u8981\u8c03\u7528 NOW() \u51fd\u6570\uff08\u5b83\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a NOW() \u767b\u5f55\u540e\u590d\u5236 \u8981\u8c03\u7528 CONCAT() \u51fd\u6570\uff08\u5b83\u5c06\u4e24\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u5728\u4e00\u8d77\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u53e5\uff1a CONCAT(&#8216;Hello&#8217;, &#8216; World&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u53c2\u6570 \u51fd\u6570\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff0c\u53c2\u6570\u53ef\u4ee5\u662f\u5e38\u91cf\u3001\u5217\u5f15\u7528\u6216\u5176\u4ed6\u51fd\u6570\u7684\u8f93\u51fa\u3002\u4f8b\u5982\uff0cDATE_FORMAT() \u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u65e5\u671f\u503c\u548c\u4e00\u4e2a\u683c\u5f0f\u5b57\u7b26\u4e32\u4f5c\u4e3a\u53c2\u6570\uff1a DATE_FORMAT(&#8216;2023-03-08&#8217;, &#8216;%Y-%m-%d&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u8fd4\u56de\u503c \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u503c\uff0c\u8be5\u503c\u53ef\u4ee5\u662f\u5404\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5982\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5e03\u5c14\u503c\u6216\u65e5\u671f\u3002\u8fd4\u56de\u7684\u503c\u53ef\u4ee5\u5b58\u50a8\u5728\u53d8\u91cf\u4e2d\uff0c\u4e0e\u5176\u4ed6\u51fd\u6570\u4e00\u8d77\u4f7f\u7528\uff0c\u6216\u7528\u4e8e\u63a7\u5236\u6267\u884c\u6d41\u7a0b\u3002 \u6ce8\u610f\u4e8b\u9879 \u51fd\u6570\u540d\u79f0\u5fc5\u987b\u662f\u5927\u5199\u3002 \u53c2\u6570\u5fc5\u987b\u4e0e\u51fd\u6570\u7684\u5b9a\u4e49\u76f8\u5339\u914d\u3002 \u5982\u679c\u51fd\u6570\u4e0d\u63a5\u53d7\u53c2\u6570\uff0c\u5219\u7701\u7565\u62ec\u53f7\u3002 \u51fd\u6570\u53ef\u4ee5\u5d4c\u5957\uff0c\u4f46\u5d4c\u5957\u7ea7\u522b\u4e0d\u5f97\u8d85\u8fc7 16 \u7ea7\u3002 \u4f7f\u7528 [&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-5224","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5224","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=5224"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5224\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}