{"id":121370,"date":"2026-11-02T15:49:53","date_gmt":"2026-11-02T07:49:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/121370.html"},"modified":"2026-11-02T15:49:53","modified_gmt":"2026-11-02T07:49:53","slug":"mysql-%e5%ae%9e%e6%88%98%e6%8c%87%e5%8d%97%ef%bc%9a%e5%9b%9b%e5%a4%a7%e6%a0%b8%e5%bf%83%e5%87%bd%e6%95%b0%ef%bc%88%e5%ad%97%e7%ac%a6%e4%b8%b2-%e6%95%b0%e5%80%bc-%e6%97%a5%e6%9c%9f-%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/121370.html","title":{"rendered":"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528"},"content":{"rendered":"<h2>MySQL\u5b66\u4e60\u8bb0\u5f55 &#8212;- \u51fd\u6570<\/h2>\n<p>\u65e5\u671f&#xff1a; 11.1<\/p>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u51fd\u6570<\/h3>\n<h4>1.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1f;<\/h4>\n<p>\u51fd\u6570\u662f\u6307\u4e00\u6bb5\u53ef\u4ee5\u76f4\u63a5\u88ab\u53e6\u4e00\u6bb5\u7a0b\u5e8f\u8c03\u7528\u7684\u7a0b\u5e8f\u6216\u4ee3\u7801\u3002<\/p>\n<h4>2.\u6709\u54ea\u4e9b\u51fd\u6570&#xff1f;<\/h4>\n<li>\u5b57\u7b26\u4e32\u51fd\u6570<\/li>\n<li>\u6570\u503c\u51fd\u6570<\/li>\n<li>\u65e5\u671f\u51fd\u6570<\/li>\n<li>\u6d41\u7a0b\u51fd\u6570<\/li>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u5b57\u7b26\u4e32\u51fd### MySQL\u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u5b57\u7b26\u4e32\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;<\/h3>\n<table>\n<tr>\u51fd\u6570\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>CONCAT(S1,S2,\u2026Sn)<\/td>\n<td>\u5b57\u7b26\u4e32\u62fc\u63a5&#xff0c;\u5c06 S1&#xff0c;S2&#xff0c;\u2026 Sn \u62fc\u63a5\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>LOWER(str)<\/td>\n<td>\u5c06\u5b57\u7b26\u4e32 str \u5168\u90e8\u8f6c\u4e3a\u5c0f\u5199<\/td>\n<\/tr>\n<tr>\n<td>UPPER(str)<\/td>\n<td>\u5c06\u5b57\u7b26\u4e32 str \u5168\u90e8\u8f6c\u4e3a\u5927\u5199<\/td>\n<\/tr>\n<tr>\n<td>LPAD(str,n,pad)<\/td>\n<td>\u5de6\u586b\u5145&#xff0c;\u7528\u5b57\u7b26\u4e32 pad \u5bf9 str \u7684\u5de6\u8fb9\u8fdb\u884c\u586b\u5145&#xff0c;\u8fbe\u5230 n \u4e2a\u5b57\u7b26\u4e32\u957f\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>RPAD(str,n,pad)<\/td>\n<td>\u53f3\u586b\u5145&#xff0c;\u7528\u5b57\u7b26\u4e32 pad \u5bf9 str \u7684\u53f3\u8fb9\u8fdb\u884c\u586b\u5145&#xff0c;\u8fbe\u5230 n \u4e2a\u5b57\u7b26\u4e32\u957f\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>TRIM(str)<\/td>\n<td>\u53bb\u6389\u5b57\u7b26\u4e32\u5934\u90e8\u548c\u5c3e\u90e8\u7684\u7a7a\u683c<\/td>\n<\/tr>\n<tr>\n<td>SUBSTRING(str,start,len)<\/td>\n<td>\u8fd4\u56de\u4ece\u5b57\u7b26\u4e32 str \u4ece start \u4f4d\u7f6e\u8d77\u7684 len \u4e2a\u957f\u5ea6\u7684\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u26a0\ufe0f \u6ce8\u610f&#xff1a;MySQL \u7684 SUBSTRING(str,start,len) \u4e2d start \u662f\u4ece 1 \u5f00\u59cb\u8ba1\u6570\u7684&#xff0c;\u800c Java \u7684 substring(beginIndex,endIndex) \u662f\u4ece 0 \u5f00\u59cb\u8ba1\u6570\u7684&#xff0c;\u4e24\u8005\u5e76\u4e0d\u4e00\u6837\u3002<\/p>\n<p>\u4f8b\u5982 substring(&#039;Hello MySQL&#039;,1,5) \u5728 MySQL \u4e2d\u8fd4\u56de Hello&#xff08;\u7b2c 1 \u4e2a\u5b57\u7b26\u8d77\u53d6 5 \u4e2a&#xff09;&#xff1b;\u800c Java \u4e2d &#034;Hello MySQL&#034;.substring(0,5) \u624d\u8fd4\u56de Hello&#xff0c;\u82e5\u5199\u6210 substring(1,5) \u5f97\u5230\u7684\u5219\u662f ello\u3002<\/p>\n<p>\u53e6\u5916&#xff0c;MySQL \u7684\u7b2c\u4e09\u4e2a\u53c2\u6570 len \u8868\u793a\u622a\u53d6\u957f\u5ea6&#xff0c;Java \u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570 endIndex \u8868\u793a\u7ed3\u675f\u4e0b\u6807&#xff08;\u4e0d\u542b&#xff09;&#xff0c;\u8bed\u4e49\u4e5f\u4e0d\u540c&#xff0c;\u8fc1\u79fb\u4ee3\u7801\u65f6\u5c24\u5176\u8981\u6ce8\u610f\u3002<\/p>\n<p>|<\/p>\n<h3>&#x1f4bb;\u7ec3\u4e60\u4ee3\u7801<\/h3>\n<p><span class=\"token comment\">&#8212; concat \u8fde\u63a5\u5b57\u7b26\u4e32<\/span><br \/>\n<span class=\"token keyword\">select<\/span> concat<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;Hello&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;MySQL&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; lower \u8f6c\u4e3a\u5c0f\u5199<\/span><br \/>\n<span class=\"token keyword\">select<\/span> lower<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;Hello&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; upper \u8f6c\u4e3a\u5927\u5199<\/span><br \/>\n<span class=\"token keyword\">select<\/span> upper<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;Hello&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; lpad \u586b\u5145\u5de6\u8fb9<\/span><br \/>\n<span class=\"token keyword\">select<\/span> lpad<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;01&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;-&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; rpad \u586b\u5145\u53f3\u8fb9<\/span><br \/>\n<span class=\"token keyword\">select<\/span> rpad<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;01&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;-&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; trim \u53bb\u6389\u5b57\u7b26\u4e32\u5934\u90e8\u548c\u5c3e\u90e8\u7684\u7a7a\u683c<\/span><br \/>\n<span class=\"token keyword\">select<\/span> trim<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;   Hello MySQL    &#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; substring \u622a\u53d6\u5b57\u7b26\u4e32<\/span><br \/>\n<span class=\"token keyword\">select<\/span> substring<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;Hello MySQL&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u7531\u4e8e\u4e1a\u52a1\u9700\u6c42\u53d8\u66f4&#xff0c;\u4f01\u4e1a\u5458\u5de5\u7684\u5de5\u53f7&#xff0c;\u7edf\u4e00\u4e3a5\u4f4d\u6570&#xff0c;\u76ee\u524d\u4e0d\u8db35\u4f4d\u6570\u7684\u5168\u90e8\u5728\u524d\u9762\u88650\u3002\u6bd4\u5982&#xff1a;1\u53f7\u5458\u5de5\u7684\u5de5\u53f7\u5e94\u8be5\u4e3a00001\u3002<\/span><br \/>\n<span class=\"token keyword\">update<\/span> emp <span class=\"token keyword\">set<\/span> workno <span class=\"token operator\">&#061;<\/span> lpad<span class=\"token punctuation\">(<\/span>workno<span class=\"token punctuation\">,<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;0&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u8fd0\u884c\u7ed3\u679c&#xff1a;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409e8653f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409eafd39.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409ec0a3e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409ed19da.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409ee2aff.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409ef348a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f1db90.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u6570\u503c\u51fd\u6570<\/h3>\n<p>MySQL \u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u6570\u503c\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u51fd\u6570\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>CEIL(x)<\/td>\n<td>\u5411\u4e0a\u53d6\u6574<\/td>\n<\/tr>\n<tr>\n<td>FLOOR(x)<\/td>\n<td>\u5411\u4e0b\u53d6\u6574<\/td>\n<\/tr>\n<tr>\n<td>MOD(x,y)<\/td>\n<td>\u8fd4\u56de x\/y \u7684\u6a21<\/td>\n<\/tr>\n<tr>\n<td>RAND()<\/td>\n<td>\u8fd4\u56de 0~1 \u5185\u7684\u968f\u673a\u6570<\/td>\n<\/tr>\n<tr>\n<td>ROUND(x,y)<\/td>\n<td>\u6c42\u53c2\u6570 x \u7684\u56db\u820d\u4e94\u5165\u7684\u503c&#xff0c;\u4fdd\u7559 y \u4f4d\u5c0f\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>&#x1f4bb;\u7ec3\u4e60\u4ee3\u7801<\/h3>\n<p><span class=\"token comment\">&#8212; \u6570\u503c\u51fd\u6570<\/span><br \/>\n<span class=\"token comment\">&#8212; ceil() \u5411\u4e0a\u53d6\u6574<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> ceil<span class=\"token punctuation\">(<\/span><span class=\"token number\">1.1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3a2<\/span><br \/>\n<span class=\"token comment\">&#8212; floor() \u5411\u4e0b\u53d6\u6574<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> floor<span class=\"token punctuation\">(<\/span><span class=\"token number\">1.9<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3a1<\/span><br \/>\n<span class=\"token comment\">&#8212; MOD(x,y)  \u8fd4\u56dex\u9664\u4ee5y\u7684\u4f59\u6570<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> <span class=\"token function\">mod<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3a3<\/span><br \/>\n<span class=\"token comment\">&#8212; RAND() \u8fd4\u56de0~1\u5185\u7684\u968f\u673a\u503c&#xff0c;\u5373[0,1)<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> rand<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u968f\u673a\u503c&#8211;0.6933717817937692<\/span><br \/>\n<span class=\"token comment\">&#8212; ROUND(x,y) \u6c42\u53c2\u6570x\u7684\u56db\u820d\u4e94\u5165\u7684\u503c&#xff0c;\u4fdd\u7559y\u4f4d\u5c0f\u6570<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> <span class=\"token function\">round<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1.234<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3a1.23<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u6848\u4f8b&#xff1a;\u901a\u8fc7\u6570\u636e\u5e93\u7684\u51fd\u6570&#xff0c;\u751f\u6210\u4e00\u4e2a\u516d\u4f4d\u6570\u7684\u968f\u673a\u9a8c\u8bc1\u7801<\/span><br \/>\n    <span class=\"token keyword\">select<\/span> lpad<span class=\"token punctuation\">(<\/span><span class=\"token function\">round<\/span><span class=\"token punctuation\">(<\/span>rand<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">*<\/span><span class=\"token number\">1000000<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><span class=\"token number\">6<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;0&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u8fd0\u884c\u7ed3\u679c&#xff1a;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f3d39e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f4e8d3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f6bb9c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f7ec63.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409f9e526.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u65e5\u671f\u51fd\u6570<\/h3>\n<p>MySQL \u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u65e5\u671f\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u51fd\u6570\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>CURDATE()<\/td>\n<td>\u8fd4\u56de\u5f53\u524d\u65e5\u671f&#xff0c;\u5e74\u6708\u65e5<\/td>\n<\/tr>\n<tr>\n<td>CURTIME()<\/td>\n<td>\u8fd4\u56de\u5f53\u524d\u65f6\u95f4 &#xff0c;\u65f6\u5206\u79d2<\/td>\n<\/tr>\n<tr>\n<td>NOW()<\/td>\n<td>\u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4 &#xff0c;\u5e74\u6708\u65e5\u65f6\u5206\u79d2<\/td>\n<\/tr>\n<tr>\n<td>YEAR(date)<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a date \u7684\u5e74\u4efd<\/td>\n<\/tr>\n<tr>\n<td>MONTH(date)<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a date \u7684\u6708\u4efd<\/td>\n<\/tr>\n<tr>\n<td>DAY(date)<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a date \u7684\u65e5\u671f<\/td>\n<\/tr>\n<tr>\n<td>DATE_ADD(date, INTERVAL expr type)<\/td>\n<td>\u8fd4\u56de\u4e00\u4e2a\u65e5\u671f\/\u65f6\u95f4\u503c\u52a0\u4e0a\u4e00\u4e2a\u65f6\u95f4\u95f4\u9694 expr \u540e\u7684\u65f6\u95f4\u503c<\/td>\n<\/tr>\n<tr>\n<td>DATEDIFF(date1,date2)<\/td>\n<td>\u8fd4\u56de\u8d77\u59cb\u65f6\u95f4 date1 \u548c \u7ed3\u675f\u65f6\u95f4 date2 \u4e4b\u95f4\u7684\u5929\u6570&#xff0c;\u6ce8&#xff1a;\u662fdate1-date2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>&#x1f4bb;\u7ec3\u4e60\u4ee3\u7801<\/h3>\n<p><span class=\"token comment\">&#8212; \u65e5\u671f\u51fd\u6570<\/span><br \/>\n<span class=\"token comment\">&#8212; curdate() \u8fd4\u56de\u5f53\u524d\u65e5\u671f,\u5e74\u6708\u65e5<\/span><br \/>\n<span class=\"token keyword\">select<\/span> curdate<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; curtime() \u8fd4\u56de\u5f53\u524d\u65f6\u95f4,\u65f6\u5206\u79d2<\/span><br \/>\n<span class=\"token keyword\">select<\/span> curtime<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; now() \u8fd4\u56de\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4,\u5e74\u6708\u65e5\u65f6\u5206\u79d2<\/span><br \/>\n<span class=\"token keyword\">select<\/span> <span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; year(date)\u83b7\u53d6\u6307\u5b9adate\u7684\u5e74\u4efd<\/span><br \/>\n<span class=\"token keyword\">select<\/span> <span class=\"token keyword\">year<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; month(date) \u83b7\u53d6\u6307\u5b9adate\u7684\u6708\u4efd<\/span><br \/>\n<span class=\"token keyword\">select<\/span> <span class=\"token keyword\">month<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; day(date) \u83b7\u53d6\u6307\u5b9adate\u7684\u65e5\u671f<\/span><br \/>\n<span class=\"token keyword\">select<\/span> <span class=\"token keyword\">day<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; date_add(date,interval expr type) \u8fd4\u56de\u4e00\u4e2a\u65e5\u671f\/\u65f6\u95f4\u503c\u52a0\u4e0a\u4e00\u4e2a\u65f6\u95f4\u95f4\u9694expr\u540e\u7684\u65f6\u95f4\u503c<\/span><br \/>\n<span class=\"token keyword\">select<\/span> date_add<span class=\"token punctuation\">(<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><span class=\"token keyword\">interval<\/span> <span class=\"token number\">70<\/span> <span class=\"token keyword\">day<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; datediff(date1,date2) \u8fd4\u56de\u8d77\u59cb\u65f6\u95f4date1\u548c\u7ed3\u675f\u65f6\u95f4date2\u4e4b\u95f4\u7684\u5929\u6570<\/span><br \/>\n<span class=\"token keyword\">select<\/span> datediff<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;2024-8-25&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u6848\u4f8b&#xff1a;\u67e5\u8be2\u6240\u6709\u5458\u5de5\u7684\u5165\u804c\u5929\u6570&#xff0c;\u5e76\u6839\u636e\u5165\u804c\u5929\u6570\u5012\u5e8f\u6392\u5e8f\u3002<\/span><br \/>\n<span class=\"token keyword\">select<\/span> name <span class=\"token punctuation\">,<\/span>datediff<span class=\"token punctuation\">(<\/span><span class=\"token function\">now<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span>emp<span class=\"token punctuation\">.<\/span>entrydate<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> entrydates <span class=\"token keyword\">from<\/span> emp <span class=\"token keyword\">order<\/span> <span class=\"token keyword\">by<\/span> entrydates <span class=\"token keyword\">desc<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u8fd0\u884c\u7ed3\u679c&#xff1a;<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409fbdca5.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409fcf2b9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409fe072e.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074951-6ae8409ff18f8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074952-6ae840a00eb6a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074952-6ae840a01f32b.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074952-6ae840a02f777.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074952-6ae840a0609ab.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u6d41\u7a0b\u51fd\u6570<\/h3>\n<h4>1.\u5e38\u89c1\u6d41\u7a0b\u51fd\u6570<\/h4>\n<p>\u662f\u5f88\u5e38\u7528\u7684\u4e00\u7c7b\u51fd\u6570&#xff0c;\u53ef\u4ee5\u5728 SQL \u8bed\u53e5\u4e2d\u5b9e\u73b0\u6761\u4ef6\u7b5b\u9009&#xff0c;\u4ece\u800c\u63d0\u9ad8\u8bed\u53e5\u7684\u6548\u7387\u3002\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u51fd\u6570\u529f\u80fd<\/tr>\n<tbody>\n<tr>\n<td>IF(value, t, f)<\/td>\n<td>\u5982\u679c value \u4e3a true&#xff0c;\u5219\u8fd4\u56de t&#xff0c;\u5426\u5219\u8fd4\u56de f<\/td>\n<\/tr>\n<tr>\n<td>IFNULL(value1, value2)<\/td>\n<td>\u5982\u679c value1 \u4e0d\u4e3a\u7a7a&#xff0c;\u8fd4\u56de value1&#xff0c;\u5426\u5219\u8fd4\u56de value2<\/td>\n<\/tr>\n<tr>\n<td>CASE WHEN [val1] THEN [res1] \u2026 ELSE [default] END<\/td>\n<td>\u5982\u679c val1 \u4e3a true&#xff0c;\u8fd4\u56de res1&#xff0c;\u2026 \u5426\u5219\u8fd4\u56de default \u9ed8\u8ba4\u503c<\/td>\n<\/tr>\n<tr>\n<td>CASE [expr] WHEN [val1] THEN [res1] \u2026 ELSE [default] END<\/td>\n<td>\u5982\u679c expr \u7684\u503c\u7b49\u4e8e val1&#xff0c;\u8fd4\u56de res1&#xff0c;\u2026 \u5426\u5219\u8fd4\u56de default \u9ed8\u8ba4\u503c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>&#x1f4bb;\u7ec3\u4e60\u4ee3\u7801<\/h3>\n<p><span class=\"token comment\">&#8212; \u6d41\u7a0b\u63a7\u5236\u51fd\u6570<\/span><br \/>\n<span class=\"token comment\">&#8212; if<\/span><br \/>\n<span class=\"token keyword\">select<\/span> <span class=\"token keyword\">if<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;Yes&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;No&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3aYes<\/span><\/p>\n<p><span class=\"token comment\">&#8212; ifnull<\/span><br \/>\n<span class=\"token keyword\">select<\/span> ifnull<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;OK&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;Default&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3aOK<\/span><br \/>\n<span class=\"token comment\">&#8212; \u8fd9\u91cc\u7684 &#039;&#039; \u662f\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32&#xff0c;\u5b83\u5e76\u4e0d\u662f NULL&#xff0c;\u662f\u4e00\u4e2a\u6709\u6548\u7684\u975e\u7a7a\u503c\u3002<\/span><br \/>\n<span class=\"token keyword\">select<\/span> ifnull<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;&#039;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;Default&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3a\u7a7a\u5b57\u7b26\u4e32<\/span><br \/>\n<span class=\"token keyword\">select<\/span> ifnull<span class=\"token punctuation\">(<\/span><span class=\"token boolean\">null<\/span><span class=\"token punctuation\">,<\/span><span class=\"token string\">&#039;Default&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">&#8212; \u7ed3\u679c\u4e3aDefault<\/span><\/p>\n<p><span class=\"token comment\">&#8212; case when then else end<\/span><br \/>\n<span class=\"token comment\">&#8212; \u9700\u6c42&#xff1a;\u67e5\u8be2emp\u8868\u7684\u5458\u5de5\u59d3\u540d\u548c\u5de5\u4f5c\u5730\u5740&#xff08;\u5317\u4eac\/\u4e0a\u6d77 &#8212;-&gt; \u4e00\u7ebf\u57ce\u5e02&#xff0c;\u5176\u4ed6 &#8212;-&gt; \u4e8c\u7ebf\u57ce\u5e02&#xff09;<\/span><br \/>\n<span class=\"token keyword\">select<\/span><br \/>\n    name<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">case<\/span> workaddress <span class=\"token keyword\">when<\/span> <span class=\"token string\">&#039;\u5317\u4eac&#039;<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u4e00\u7ebf\u57ce\u5e02&#039;<\/span> <span class=\"token keyword\">when<\/span> <span class=\"token string\">&#039;\u4e0a\u6d77&#039;<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u4e00\u7ebf\u57ce\u5e02&#039;<\/span><span class=\"token keyword\">else<\/span> <span class=\"token string\">&#039;\u4e8c\u7ebf\u57ce\u5e02&#039;<\/span><span class=\"token keyword\">end<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token string\">&#039;\u5de5\u4f5c\u5730\u5740&#039;<\/span><br \/>\n<span class=\"token keyword\">from<\/span> emp<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u6848\u4f8b&#xff1a;\u7edf\u8ba1\u73ed\u7ea7\u5404\u4e2a\u5b66\u5458\u7684\u6210\u7ee9&#xff0c;\u5c55\u793a\u7684\u89c4\u5219\u5982\u4e0b&#xff1a;<\/span><br \/>\n<span class=\"token comment\">&#8212; &gt;&#061; 85&#xff0c;\u5c55\u793a\u4f18\u79c0<\/span><br \/>\n<span class=\"token comment\">&#8212; &gt;&#061; 60&#xff0c;\u5c55\u793a\u53ca\u683c<\/span><br \/>\n<span class=\"token comment\">&#8212; \u5426\u5219&#xff0c;\u5c55\u793a\u4e0d\u53ca\u683c<\/span><br \/>\n<span class=\"token comment\">&#8212; \u65b0\u5efa\u8868\u683c<\/span><br \/>\n<span class=\"token keyword\">create<\/span> <span class=\"token keyword\">table<\/span> score<span class=\"token punctuation\">(<\/span><br \/>\n    id <span class=\"token keyword\">int<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;ID&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    name <span class=\"token keyword\">varchar<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">20<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;\u59d3\u540d&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    math <span class=\"token keyword\">int<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;\u6570\u5b66\u6210\u7ee9&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    english <span class=\"token keyword\">int<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;\u82f1\u8bed\u6210\u7ee9&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    chinese <span class=\"token keyword\">int<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;\u8bed\u6587\u6210\u7ee9&#039;<\/span><br \/>\n<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">comment<\/span> <span class=\"token string\">&#039;\u5b66\u751f\u6210\u7ee9\u8868&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">&#8212; \u63d2\u5165\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">insert<\/span> <span class=\"token keyword\">into<\/span> score<span class=\"token punctuation\">(<\/span>id<span class=\"token punctuation\">,<\/span> name<span class=\"token punctuation\">,<\/span> math<span class=\"token punctuation\">,<\/span> english<span class=\"token punctuation\">,<\/span> chinese<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">values<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Tom&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">67<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">88<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">95<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Rose&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">23<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">66<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">90<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Jack&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">56<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">98<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">76<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">select<\/span><br \/>\n    id<span class=\"token punctuation\">,<\/span><br \/>\n    name<span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">case<\/span> <span class=\"token keyword\">when<\/span> math <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">85<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u4f18\u79c0&#039;<\/span> <span class=\"token keyword\">when<\/span> math <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">60<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token string\">&#039;\u4e0d\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">end<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token string\">&#039;\u6570\u5b66\u6210\u7ee9&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">case<\/span> <span class=\"token keyword\">when<\/span> english <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">85<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u4f18\u79c0&#039;<\/span> <span class=\"token keyword\">when<\/span> english <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">60<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token string\">&#039;\u4e0d\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">end<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token string\">&#039;\u82f1\u8bed\u6210\u7ee9&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">case<\/span> <span class=\"token keyword\">when<\/span> chinese <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">85<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u4f18\u79c0&#039;<\/span> <span class=\"token keyword\">when<\/span> chinese <span class=\"token operator\">&gt;&#061;<\/span> <span class=\"token number\">60<\/span> <span class=\"token keyword\">then<\/span> <span class=\"token string\">&#039;\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token string\">&#039;\u4e0d\u53ca\u683c&#039;<\/span> <span class=\"token keyword\">end<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token string\">&#039;\u8bed\u6587\u6210\u7ee9&#039;<\/span><br \/>\n<span class=\"token keyword\">from<\/span> score<span class=\"token punctuation\">;<\/span><\/p>\n<h4>\u8fd0\u884c\u7ed3\u679c&#xff1a;<\/h4>\n<p><img decoding=\"async\" src=\"2026-11-02hukxj52h54t.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"2026-11-02w3dxxc43olt.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"2026-11-02fvplrqpxfxb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"2026-11-02cyks0xry1f3.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"2026-11-020bxblpahrv2.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"2026-11-02jkbh1hpcbyc.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u51fd\u6570\u5c0f\u7ed3<\/h3>\n<h4>1.\u603b\u7ed3&#xff1a;<\/h4>\n<li>\u5b57\u7b26\u4e32\u51fd\u6570&#xff1a;CONCAT, LOWER, UPPER, LPAD, RPAD, TRIM, SUBSTRING<\/li>\n<li>\u6570\u503c\u51fd\u6570&#xff1a;CEIL, FLOOR, MOD, RAND, ROUND<\/li>\n<li>\u65e5\u671f\u51fd\u6570&#xff1a;CURDATE, CURTIME, NOW, YEAR, MONTH, DAY, DATE_ADD, DATEDIFF<\/li>\n<li>\u6d41\u7a0b\u51fd\u6570&#xff1a;IF, IFNULL, CASE [\u2026] WHEN \u2026 THEN \u2026 ELSE \u2026 END<\/li>\n<h4>2.\u573a\u666f\u5e94\u7528\u8bf4\u660e<\/h4>\n<p>DATEDIFF: \u6570\u636e\u5e93\u8868\u4e2d&#xff0c;\u5b58\u50a8\u7684\u662f\u5165\u804c\u65e5\u671f&#xff0c;\u5982 2000-11-12&#xff0c;\u5982\u4f55\u5feb\u901f\u8ba1\u7b97\u5165\u804c\u5929\u6570&#xff1f;&#xff1f;&#xff1f;&#xff08;\u4f8b\u5982&#xff1a;\u52a0\u5165\u516c\u53f8\u5929\u6570 1495\u5929&#xff09;<\/p>\n<p>CASE \u2026 WHEN \u2026: \u6570\u636e\u5e93\u8868\u4e2d&#xff0c;\u5b58\u50a8\u7684\u662f\u5b66\u751f\u7684\u5206\u6570\u503c&#xff0c;\u598298\u300175&#xff0c;\u5982\u4f55\u5feb\u901f\u5224\u5b9a\u5206\u6570\u7684\u7b49\u7ea7\u5462&#xff1f;&#xff1f;&#xff1f;&#xff08;\u4f8b\u5982&#xff1a;\u5224\u5b9a\u4e3a\u201c\u53ca\u683c\u201d\u3001\u201c\u4f18\u79c0\u201d\u7b49&#xff09;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u5b66\u4e60\u8bb0\u5f55 &#8212;- \u51fd\u6570<br \/>\n\u65e5\u671f&#xff1a; 11.1<br \/>\n&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u51fd\u6570<br \/>\n1.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1f;<br \/>\n\u51fd\u6570\u662f\u6307\u4e00\u6bb5\u53ef\u4ee5\u76f4\u63a5\u88ab\u53e6\u4e00\u6bb5\u7a0b\u5e8f\u8c03\u7528\u7684\u7a0b\u5e8f\u6216\u4ee3\u7801\u3002<br \/>\n2.\u6709\u54ea\u4e9b\u51fd\u6570&#xff1f;<br \/>\n\u5b57\u7b26\u4e32\u51fd\u6570\u6570\u503c\u51fd\u6570\u65e5\u671f\u51fd\u6570\u6d41\u7a0b\u51fd\u6570<br \/>\n&#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u5b57\u7b26\u4e32\u51fd### MySQL\u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u5b57\u7b26\u4e32\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;\u51fd\u6570\u529f\u80fdCONCAT(S1,S2,\u2026Sn)\u5b57\u7b26\u4e32\u62fc\u63a5&#xff0c;\u5c06 S1&#xff0c;<\/p>\n","protected":false},"author":2,"featured_media":121350,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[114,371,123,100,305],"topic":[],"class_list":["post-121370","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-mysql","tag-371","tag-123","tag-100","tag-305"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/121370.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"MySQL\u5b66\u4e60\u8bb0\u5f55 ---- \u51fd\u6570 \u65e5\u671f&#xff1a; 11.1 &#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u51fd\u6570 1.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1f; \u51fd\u6570\u662f\u6307\u4e00\u6bb5\u53ef\u4ee5\u76f4\u63a5\u88ab\u53e6\u4e00\u6bb5\u7a0b\u5e8f\u8c03\u7528\u7684\u7a0b\u5e8f\u6216\u4ee3\u7801\u3002 2.\u6709\u54ea\u4e9b\u51fd\u6570&#xff1f; \u5b57\u7b26\u4e32\u51fd\u6570\u6570\u503c\u51fd\u6570\u65e5\u671f\u51fd\u6570\u6d41\u7a0b\u51fd\u6570 &#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u5b57\u7b26\u4e32\u51fd### MySQL\u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u5b57\u7b26\u4e32\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;\u51fd\u6570\u529f\u80fdCONCAT(S1,S2,\u2026Sn)\u5b57\u7b26\u4e32\u62fc\u63a5&#xff0c;\u5c06 S1&#xff0c;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/121370.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-02T07:49:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409e8653f.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121370.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/121370.html\",\"name\":\"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-02T07:49:53+00:00\",\"dateModified\":\"2026-11-02T07:49:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/121370.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/121370.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/121370.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/121370.html","og_locale":"zh_CN","og_type":"article","og_title":"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"MySQL\u5b66\u4e60\u8bb0\u5f55 ---- \u51fd\u6570 \u65e5\u671f&#xff1a; 11.1 &#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u51fd\u6570 1.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1f; \u51fd\u6570\u662f\u6307\u4e00\u6bb5\u53ef\u4ee5\u76f4\u63a5\u88ab\u53e6\u4e00\u6bb5\u7a0b\u5e8f\u8c03\u7528\u7684\u7a0b\u5e8f\u6216\u4ee3\u7801\u3002 2.\u6709\u54ea\u4e9b\u51fd\u6570&#xff1f; \u5b57\u7b26\u4e32\u51fd\u6570\u6570\u503c\u51fd\u6570\u65e5\u671f\u51fd\u6570\u6d41\u7a0b\u51fd\u6570 &#x1f4d6;\u4eca\u65e5\u77e5\u8bc6\u70b9 \u2014\u2014\u5b57\u7b26\u4e32\u51fd### MySQL\u4e2d\u5185\u7f6e\u4e86\u5f88\u591a\u5b57\u7b26\u4e32\u51fd\u6570&#xff0c;\u5e38\u7528\u7684\u51e0\u4e2a\u5982\u4e0b&#xff1a;\u51fd\u6570\u529f\u80fdCONCAT(S1,S2,\u2026Sn)\u5b57\u7b26\u4e32\u62fc\u63a5&#xff0c;\u5c06 S1&#xff0c;","og_url":"https:\/\/www.wsisp.com\/helps\/121370.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-02T07:49:53+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261102074950-6ae8409e8653f.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/121370.html","url":"https:\/\/www.wsisp.com\/helps\/121370.html","name":"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-02T07:49:53+00:00","dateModified":"2026-11-02T07:49:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/121370.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/121370.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/121370.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"MySQL \u5b9e\u6218\u6307\u5357\uff1a\u56db\u5927\u6838\u5fc3\u51fd\u6570\uff08\u5b57\u7b26\u4e32\/\u6570\u503c\/\u65e5\u671f\/\u6d41\u7a0b\uff09\u8be6\u89e3\u4e0e\u6848\u4f8b\u5e94\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/121370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=121370"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/121370\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/121350"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=121370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=121370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=121370"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=121370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}