{"id":28089,"date":"2024-11-24T09:30:27","date_gmt":"2024-11-24T01:30:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28089\/"},"modified":"2024-11-24T09:30:27","modified_gmt":"2024-11-24T01:30:27","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-mysql-%e4%b8%ad%e9%92%88%e5%af%b9%e5%8c%85%e5%90%ab%e5%a4%9a%e4%b8%aa%e6%97%a5%e6%9c%9f%e5%80%bc%e7%9a%84%e5%ad%97%e6%ae%b5%e8%bf%9b%e8%a1%8c%e7%89%b9%e5%ae%9a%e6%97%a5-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28089\/","title":{"rendered":"\u5982\u4f55\u5728 MySQL \u4e2d\u9488\u5bf9\u5305\u542b\u591a\u4e2a\u65e5\u671f\u503c\u7684\u5b57\u6bb5\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173139484228677.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5728 MySQL \u4e2d\u9488\u5bf9\u5305\u542b\u591a\u4e2a\u65e5\u671f\u503c\u7684\u5b57\u6bb5\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5728 MySQL \u4e2d\u9488\u5bf9\u5305\u542b\u591a\u4e2a\u65e5\u671f\u503c\u7684\u5b57\u6bb5\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728\u5b58\u5728\u591a\u4e2a\u65e5\u671f\u503c\u7684\u540c\u4e2a\u5b57\u6bb5\u4e2d\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2<\/strong><\/p>\n<p>\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u67d0\u4e9b\u5b57\u6bb5\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u65e5\u671f\u503c\uff0c\u4f8b\u5982\uff1a&#8221;2022-09-14 11:38:21,2022-09-14 18:00:00&#8243;\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u8fd9\u7c7b\u5b57\u6bb5\u65f6\uff0c\u53ea\u80fd\u901a\u8fc7\u7b80\u5355\u7684\u8303\u56f4\u67e5\u8be2\u6765\u83b7\u53d6\u7279\u5b9a\u65e5\u671f\u5185\u7684\u6570\u636e\uff0c\u800c\u65e0\u6cd5\u9488\u5bf9\u5206\u5272\u540e\u7684\u65f6\u95f4\u8303\u56f4\u8fdb\u884c\u67e5\u8be2\u3002<\/p>\n<p><strong> \u67e5\u8be2\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u8981\u5b9e\u73b0\u9488\u5bf9\u5206\u5272\u540e\u65f6\u95f4\u8303\u56f4\u7684\u67e5\u8be2\uff0c\u9700\u8981\u5c06\u8be5\u5b57\u6bb5\u4e2d\u7684\u6bcf\u4e2a\u65f6\u95f4\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u6761\u4ef6\u8fdb\u884c\u5224\u65ad\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 substring_index() \u51fd\u6570\u6765\u5b9e\u73b0\u6b64\u76ee\u7684\u7684 mysql \u67e5\u8be2\u793a\u4f8b\uff1a<\/p>\n<pre>select\n    epr.*\nfrom\n    event_plan_record epr\nwhere\n    substring_index(epr.realStartTime, ',', 1) BETWEEN #{startDate} AND #{endDate}\n    or substring_index(epr.realStartTime, ',', -1) BETWEEN #{startDate} AND #{endDate}\n    or #{startDate} BETWEEN substring_index(epr.realStartTime, ',', 1) AND substring_index(epr.realStartTime, ',', -1)\n    or #{endDate} BETWEEN substring_index(epr.realStartTime, ',', 1) AND substring_index(epr.realStartTime, ',', -1)\norder by epr.realStartTime desc\nlimit #{page},#{count};<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u67e5\u8be2\u5224\u65ad\u4e86\u56db\u79cd\u53ef\u80fd\u7684\u60c5\u51b5\uff1a<\/p>\n<ol>\n<li>\u7b2c\u4e00\u4e2a\u5206\u5272\u7684\u65f6\u95f4\u503c\u5728\u7ed9\u5b9a\u8303\u56f4\u5185<\/li>\n<li>\u6700\u540e\u4e00\u4e2a\u5206\u5272\u7684\u65f6\u95f4\u503c\u5728\u7ed9\u5b9a\u8303\u56f4\u5185<\/li>\n<li>\u7ed9\u5b9a\u8303\u56f4\u5f00\u59cb\u65f6\u95f4\u5728\u65f6\u95f4\u503c\u8303\u56f4\u5185<\/li>\n<li>\u7ed9\u5b9a\u8303\u56f4\u7ed3\u675f\u65f6\u95f4\u5728\u65f6\u95f4\u503c\u8303\u56f4\u5185<\/li>\n<\/ol>\n<p>\u5982\u679c\u6ee1\u8db3\u4efb\u4f55\u4e00\u79cd\u60c5\u51b5\uff0c\u67e5\u8be2\u5c06\u8fd4\u56de\u8be5\u8bb0\u5f55\uff0c\u5e76\u4e14\u53ea\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u7684\u8bb0\u5f55\u4e2d\u6700\u65b0\u7684\u4e00\u6761\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728 MySQL \u4e2d\u9488\u5bf9\u5305\u542b\u591a\u4e2a\u65e5\u671f\u503c\u7684\u5b57\u6bb5\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b58\u5728\u591a\u4e2a\u65e5\u671f\u503c\u7684\u540c\u4e2a\u5b57\u6bb5\u4e2d\u8fdb\u884c\u7279\u5b9a\u65e5\u671f\u8303\u56f4\u67e5\u8be2 \u5728\u6570\u636e\u5e93\u4e2d\uff0c\u67d0\u4e9b\u5b57\u6bb5\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u65e5\u671f\u503c\uff0c\u4f8b\u5982\uff1a&#8221;2022-09-14 11:38:21,2022-09-14 18:00:00&#8243;\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u67e5\u8be2\u8fd9\u7c7b\u5b57\u6bb5\u65f6\uff0c\u53ea\u80fd\u901a\u8fc7\u7b80\u5355\u7684\u8303\u56f4\u67e5\u8be2\u6765\u83b7\u53d6\u7279\u5b9a\u65e5\u671f\u5185\u7684\u6570\u636e\uff0c\u800c\u65e0\u6cd5\u9488\u5bf9\u5206\u5272\u540e\u7684\u65f6\u95f4\u8303\u56f4\u8fdb\u884c\u67e5\u8be2\u3002 \u67e5\u8be2\u89e3\u51b3\u65b9\u6848 \u8981\u5b9e\u73b0\u9488\u5bf9\u5206\u5272\u540e\u65f6\u95f4\u8303\u56f4\u7684\u67e5\u8be2\uff0c\u9700\u8981\u5c06\u8be5\u5b57\u6bb5\u4e2d\u7684\u6bcf\u4e2a\u65f6\u95f4\u4f5c\u4e3a\u4e00\u4e2a\u72ec\u7acb\u6761\u4ef6\u8fdb\u884c\u5224\u65ad\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528 substring_index() \u51fd\u6570\u6765\u5b9e\u73b0\u6b64\u76ee\u7684\u7684 mysql \u67e5\u8be2\u793a\u4f8b\uff1a select epr.* from event_plan_record epr where substring_index(epr.realStartTime, &#8216;,&#8217;, 1) BETWEEN #{startDate} AND #{endDate} or substring_index(epr.realStartTime, &#8216;,&#8217;, -1) BETWEEN #{startDate} AND #{endDate} or #{startDate} BETWEEN substring_index(epr.realStartTime, &#8216;,&#8217;, 1) AND substring_index(epr.realStartTime, &#8216;,&#8217;, -1) or #{endDate} BETWEEN substring_index(epr.realStartTime, &#8216;,&#8217;, 1) AND substring_index(epr.realStartTime, &#8216;,&#8217;, -1) order by epr.realStartTime desc [&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-28089","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28089","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=28089"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28089\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}