{"id":157,"date":"2011-12-27T15:36:26","date_gmt":"2011-12-27T15:36:26","guid":{"rendered":"https:\/\/shan.info\/new\/concat-mysql\/"},"modified":"2011-12-27T15:36:26","modified_gmt":"2011-12-27T15:36:26","slug":"concat-mysql","status":"publish","type":"post","link":"https:\/\/shan.info\/new\/concat-mysql\/","title":{"rendered":"CONCAT mysql"},"content":{"rendered":"<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<div class=\"blockcode\"><code id=\"code\">CONCAT(str1,str2,\u2026) <\/code><\/div>\n<p>\u8fd4\u56de\u7ed3\u679c\u4e3a\u8fde\u63a5\u53c2\u6570\u4ea7\u751f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3aNULL \uff0c\u5219\u8fd4\u56de\u503c\u4e3a NULL\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\uff1a<\/p>\n<div class=\"blockcode\"><code id=\"code\">CONCAT(str1,str2,\u2026) <\/code><\/div>\n<p>\u8fd4\u56de\u7ed3\u679c\u4e3a\u8fde\u63a5\u53c2\u6570\u4ea7\u751f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3aNULL \uff0c\u5219\u8fd4\u56de\u503c\u4e3a NULL\u3002<\/p>\n<p>\u5982\u679c\u6240\u6709\u53c2\u6570\u5747\u4e3a\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002 <br \/> \u5982\u679c\u81ea\u53d8\u91cf\u4e2d\u542b\u6709\u4efb\u4e00\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5219\u7ed3\u679c\u4e3a\u4e00\u4e2a\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002<br \/> \u4e00\u4e2a\u6570\u5b57\u53c2\u6570\u88ab\u8f6c\u5316\u4e3a\u4e0e\u4e4b\u76f8\u7b49\u7684\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u683c\u5f0f\uff1b\u82e5\u8981\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u53ef\u4f7f\u7528\u663e\u5f0f\u7c7b\u578b cast, \u4f8b\u5982\uff1a<\/p>\n<div class=\"blockcode\"><code id=\"code1\">SELECT CONCAT(CAST(int_col AS CHAR), char_col)<\/code><\/div>\n<p>MySQL\u7684concat\u51fd\u6570\u53ef\u4ee5\u8fde\u63a5\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5b57\u7b26\u4e32,\u5982<\/p>\n<div class=\"blockcode\"><code id=\"code2\">mysql&gt; select concat('10');<br \/> +--------------+<br \/> | concat('10') |<br \/> +--------------+<br \/> | 10\u00a0 \u00a0|<br \/> +--------------+<br \/> 1 row in set (0.00 sec)<\/p>\n<p> mysql&gt; select concat('11','22','33');<br \/> +------------------------+<br \/> | concat('11','22','33') |<br \/> +------------------------+<br \/> | 112233 |<br \/> +------------------------+<br \/> 1 row in set (0.00 sec)<\/code><\/div>\n<p>MySQL\u7684concat\u51fd\u6570\u5728\u8fde\u63a5\u5b57\u7b26\u4e32\u7684\u65f6\u5019\uff0c\u53ea\u8981\u5176\u4e2d\u4e00\u4e2a\u662fNULL,\u90a3\u4e48\u5c06\u8fd4\u56deNULL<code id=\"code3\">mysql&gt; select concat('11','22',null);<br \/> +------------------------+<br \/> | concat('11','22',null) |<br \/> +------------------------+<br \/> | NULL\u00a0 \u00a0|<br \/> +------------------------+<br \/> 1 row in set (0.00 sec)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u65b9\u6cd5\uff1a CONCAT(str1,str2,\u2026) \u8fd4\u56de\u7ed3\u679c\u4e3a\u8fde\u63a5\u53c2\u6570\u4ea7\u751f\u7684\u5b57\u7b26\u4e32\u3002\u5982\u6709\u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\u4e3aNULL \uff0c\u5219\u8fd4\u56de\u503c\u4e3a NULL\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":0,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"wp:attachment":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}