{"id":119,"date":"2023-06-28T16:37:13","date_gmt":"2023-06-28T08:37:13","guid":{"rendered":"https:\/\/jiachen.de.cool\/blog\/?p=119"},"modified":"2023-06-28T16:43:50","modified_gmt":"2023-06-28T08:43:50","slug":"%e6%af%94%e8%be%83%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%a4%a7%e5%b0%8f%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/jiachen.de.cool\/blog\/2023\/06\/28\/%e6%af%94%e8%be%83%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%a4%a7%e5%b0%8f%e5%87%bd%e6%95%b0\/","title":{"rendered":"\u6bd4\u8f83\u5b57\u7b26\u4e32\u5927\u5c0f\u51fd\u6570"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">length()\u8fd4\u56de\u5b57\u8282\u957f\u5ea6\uff0c\u4e00\u4e2a\u591a\u5b57\u8282\u5b57\u7b26\u7b97\u4f5c\u591a\u4e2a\u5b57\u8282\u3002\uff08utf8\u7f16\u7801\uff1a\u4e00\u4e2a\u6c49\u5b573\u4e2a\u5b57\u8282\uff0c\u4e00\u4e2a\u6570\u5b57\u6216\u5b57\u6bcd1\u4e2a\u5b57\u8282\u3002gbk\u7f16\u7801\uff1a\u4e00\u4e2a\u6c49\u5b572\u4e2a\u5b57\u8282\uff0c\u4e00\u4e2a\u6570\u5b57\u6216\u5b57\u6bcd1\u4e2a\u5b57\u8282\u3002\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">char_lenth()\u8fd4\u56de\u5b57\u7b26\u957f\u5ea6\uff0c\u4e00\u4e2a\u591a\u5b57\u8282\u5b57\u7b26\u7b97\u4f5c\u4e00\u4e2a\u5b57\u7b26\u3002\u5373\u4e0d\u7ba1\u662f\u6c49\u5b57\u8fd8\u662f\u6570\u5b57\u6216\u5b57\u6bcd\u90fd\u7b97\u662f1\u4e2a\u5b57\u7b26\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">strcmp()\u6bd4\u8f83\u5b57\u7b26\u4e32\u5927\u5c0f\u51fd\u6570\uff0c\u5982\u679c\u53c2\u6570str1\u5927\u4e8estr2\uff0c\u8fd4\u56de1\uff1b\u5982\u679cstr1\u5c0f\u4e8estr2\uff0c\u8fd4\u56de-1\uff1b\u5982\u679cstr1\u7b49\u4e8estr2\u5219\u8fd4\u56de0\u3002\u6bd4\u8f83\u5b57\u7b26\u4e32\u5927\u5c0f\u51fd\u6570\u662f\u57fa\u4e8e\u5f53\u524d\u7684\u5b57\u7b26\u96c6\uff0c\u4e0d\u540c\u5b57\u7b26\u96c6\u6bd4\u8f83\u7ed3\u679c\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; select length('mysql'),length('\u6c49\u5b57'),char_length('mysql'),char_length('\n\u6c49\u5b57');\n+-----------------+------------------+----------------------+-------------------\n----+\n| length('mysql') | length('\u6c49\u5b57')   | char_length('mysql') | char_length('\u6c49\u5b57'\n)   |\n+-----------------+------------------+----------------------+-------------------\n----+\n|               5 |                6 |                    5 |\n  2 |\n+-----------------+------------------+----------------------+-------------------\n----+\n1 row in set (0.01 sec)\n\nmysql&gt; select length(ceil(-2.5)),char_length(ceil(-2.5));\n+--------------------+-------------------------+\n| length(ceil(-2.5)) | char_length(ceil(-2.5)) |\n+--------------------+-------------------------+\n|                  2 |                       2 |\n+--------------------+-------------------------+\n1 row in set (0.01 sec)\n\nmysql&gt; select ceil(-2.5);\/*\u53d6\u6574\u51fd\u6570*\/\n+------------+\n| ceil(-2.5) |\n+------------+\n|         -2 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select ceil(3.8);\n+-----------+\n| ceil(3.8) |\n+-----------+\n|         4 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql&gt; select ceil(-3.8);\n+------------+\n| ceil(-3.8) |\n+------------+\n|         -3 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select ceil(-2.1);\n+------------+\n| ceil(-2.1) |\n+------------+\n|         -2 |\n+------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select ceil(2.1);\n+-----------+\n| ceil(2.1) |\n+-----------+\n|         3 |\n+-----------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('abc','abd'),strcmp('abc','abc'),strcmp('abc','abb');\n+---------------------+---------------------+---------------------+\n| strcmp('abc','abd') | strcmp('abc','abc') | strcmp('abc','abb') |\n+---------------------+---------------------+---------------------+\n|                  -1 |                   0 |                   1 |\n+---------------------+---------------------+---------------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('1','2');\n+-----------------+\n| strcmp('1','2') |\n+-----------------+\n|              -1 |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('a','A');\n+-----------------+\n| strcmp('a','A') |\n+-----------------+\n|               0 |\n+-----------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('\u4f60','\u6211');\n+---------------------+\n| strcmp('\u4f60','\u6211')   |\n+---------------------+\n|                  -1 |\n+---------------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('ab','abc');\n+--------------------+\n| strcmp('ab','abc') |\n+--------------------+\n|                 -1 |\n+--------------------+\n1 row in set (0.00 sec)\n\nmysql&gt; select strcmp('21','3');\n+------------------+\n| strcmp('21','3') |\n+------------------+\n|               -1 |\n+------------------+\n1 row in set (0.00 sec)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>length()\u8fd4\u56de\u5b57\u8282\u957f\u5ea6\uff0c\u4e00\u4e2a\u591a\u5b57\u8282\u5b57\u7b26\u7b97\u4f5c\u591a\u4e2a\u5b57\u8282\u3002\uff08utf8\u7f16\u7801\uff1a\u4e00\u4e2a\u6c49\u5b573\u4e2a\u5b57\u8282\uff0c\u4e00\u4e2a\u6570\u5b57\u6216\u5b57\u6bcd1\u4e2a&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/jiachen.de.cool\/blog\/2023\/06\/28\/%e6%af%94%e8%be%83%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%a4%a7%e5%b0%8f%e5%87%bd%e6%95%b0\/\">Read the full article<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[23,20,22],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-23","tag-20","tag-22"],"_links":{"self":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":2,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":122,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions\/122"}],"wp:attachment":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}