{"id":27182,"date":"2024-11-24T12:22:05","date_gmt":"2024-11-24T04:22:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27182\/"},"modified":"2024-11-24T12:22:05","modified_gmt":"2024-11-24T04:22:05","slug":"mysql-%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8b%e5%8f%82%e6%95%b0%e6%8a%a5%e9%94%99%ef%bc%9adataname-%e4%b8%ba%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%97%b6%e4%b8%ba%e4%bb%80%e4%b9%88%e6%89%a7%e8%a1%8c%e5%a4%b1-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27182\/","title":{"rendered":"MySQL \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\uff1aDataName \u4e3a\u5b57\u7b26\u4e32\u65f6\u4e3a\u4ec0\u4e48\u6267\u884c\u5931\u8d25\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173120640213256.jpg\" class=\"aligncenter\" title=\"MySQL \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\uff1aDataName \u4e3a\u5b57\u7b26\u4e32\u65f6\u4e3a\u4ec0\u4e48\u6267\u884c\u5931\u8d25\uff1f\u63d2\u56fe\" alt=\"MySQL \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\uff1aDataName \u4e3a\u5b57\u7b26\u4e32\u65f6\u4e3a\u4ec0\u4e48\u6267\u884c\u5931\u8d25\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\u7684\u6839\u672c\u539f\u56e0<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 mysql \u5b58\u50a8\u8fc7\u7a0b\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u5982\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre>procedure execution failed\n1054 - unknown column '\u738b\u5c0f\u674e' in 'field list'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u610f\u5473\u7740\u5b58\u50a8\u8fc7\u7a0b\u6267\u884c\u5931\u8d25\uff0c\u9519\u8bef\u539f\u56e0\u662f\u5b57\u6bb5\u5217\u8868\u4e2d\u4e0d\u5b58\u5728\u540d\u4e3a &#8220;\u738b\u5c0f\u674e&#8221; \u7684\u5b57\u6bb5\u3002<\/p>\n<p>\u5982\u9898\u4e3b\u6240\u8ff0\uff0c\u95ee\u9898\u51fa\u73b0\u5728\u5f53 dataname \u53c2\u6570\u4e3a\u5b57\u7b26\u4e32\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u62a5\u9519\u3002\u539f\u56e0\u53ef\u80fd\u662f:<\/p>\n<p><strong>\u5b57\u7b26\u4e32\u62fc\u63a5\u64cd\u4f5c\u4e0d\u6b63\u786e<\/strong><\/p>\n<p>\u5728\u5b58\u50a8\u8fc7\u7a0b\u7684 if \u8bed\u53e5\u4e2d\uff0c\u7528\u4e8e\u62fc\u63a5\u5b57\u7b26\u4e32\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>concat('%',dataname,'%')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0cdataname \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u53d8\u91cf\u3002\u4f46\u662f\uff0c\u62fc\u63a5\u5b57\u7b26\u4e32\u65f6\u9700\u8981\u8003\u8651\u7279\u6b8a\u5b57\u7b26\u8f6c\u4e49\u3002\u5bf9\u4e8e mysql\uff0c\u9700\u8981\u4f7f\u7528 \u5b57\u7b26\u8fdb\u884c\u8f6c\u4e49\u3002\u56e0\u6b64\uff0c\u6b63\u786e\u7684\u4ee3\u7801\u5e94\u8be5\u662f\uff1a<\/p>\n<pre>concat('%',dataname,'%')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\u7684\u6570\u636e\u7c7b\u578b\u4e0d\u5339\u914d<\/strong><\/p>\n<p>\u786e\u4fdd\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\uff0c\u4f20\u5165\u7684 dataname \u53c2\u6570\u4e0e\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u4e2d\u7684\u53c2\u6570\u6570\u636e\u7c7b\u578b\u5339\u914d\u3002\u6839\u636e\u9898\u4e3b\u63d0\u4f9b\u7684\u4fe1\u606f\uff0c\u5f53 dataname \u8bbe\u7f6e\u4e3a int \u6574\u578b\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u6b63\u5e38\u6267\u884c\u3002\u8fd9\u8868\u660e\u95ee\u9898\u53ef\u80fd\u51fa\u5728\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6 dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u9519\u8bef\u3002<\/p>\n<p><strong>\u5176\u4ed6\u53ef\u80fd\u7684\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u5982\u679c\u4ee5\u4e0a\u5efa\u8bae\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u8fd8\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<ul>\n<li>\u68c0\u67e5\u5b58\u50a8\u8fc7\u7a0b\u7684\u5b9a\u4e49\u662f\u5426\u6b63\u786e\uff0c\u786e\u4fdd dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u6b63\u786e\u3002<\/li>\n<li>\u68c0\u67e5\u5b58\u50a8\u8fc7\u7a0b\u7684\u8c03\u7528\u8bed\u53e5\uff0c\u786e\u4fdd\u4f20\u5165\u7684 dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u4e0e\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u5339\u914d\u3002<\/li>\n<li>\u5c1d\u8bd5\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u8c03\u8bd5\u5de5\u5177\u6765\u8ddf\u8e2a\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\uff1aDataName \u4e3a\u5b57\u7b26\u4e32\u65f6\u6267\u884c\u5931\u8d25\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>\u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u62a5\u9519\u7684\u6839\u672c\u539f\u56e0 \u5728\u4f7f\u7528 mysql \u5b58\u50a8\u8fc7\u7a0b\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u5982\u4e0b\u9519\u8bef\uff1a procedure execution failed 1054 &#8211; unknown column &#8216;\u738b\u5c0f\u674e&#8217; in &#8216;field list&#8217; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u610f\u5473\u7740\u5b58\u50a8\u8fc7\u7a0b\u6267\u884c\u5931\u8d25\uff0c\u9519\u8bef\u539f\u56e0\u662f\u5b57\u6bb5\u5217\u8868\u4e2d\u4e0d\u5b58\u5728\u540d\u4e3a &#8220;\u738b\u5c0f\u674e&#8221; \u7684\u5b57\u6bb5\u3002 \u5982\u9898\u4e3b\u6240\u8ff0\uff0c\u95ee\u9898\u51fa\u73b0\u5728\u5f53 dataname \u53c2\u6570\u4e3a\u5b57\u7b26\u4e32\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u62a5\u9519\u3002\u539f\u56e0\u53ef\u80fd\u662f: \u5b57\u7b26\u4e32\u62fc\u63a5\u64cd\u4f5c\u4e0d\u6b63\u786e \u5728\u5b58\u50a8\u8fc7\u7a0b\u7684 if \u8bed\u53e5\u4e2d\uff0c\u7528\u4e8e\u62fc\u63a5\u5b57\u7b26\u4e32\u7684\u4ee3\u7801\u5982\u4e0b\uff1a concat(&#8216;%&#8217;,dataname,&#8217;%&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cdataname \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u53d8\u91cf\u3002\u4f46\u662f\uff0c\u62fc\u63a5\u5b57\u7b26\u4e32\u65f6\u9700\u8981\u8003\u8651\u7279\u6b8a\u5b57\u7b26\u8f6c\u4e49\u3002\u5bf9\u4e8e mysql\uff0c\u9700\u8981\u4f7f\u7528 \u5b57\u7b26\u8fdb\u884c\u8f6c\u4e49\u3002\u56e0\u6b64\uff0c\u6b63\u786e\u7684\u4ee3\u7801\u5e94\u8be5\u662f\uff1a concat(&#8216;%&#8217;,dataname,&#8217;%&#8217;) \u767b\u5f55\u540e\u590d\u5236 \u767b\u5f55\u540e\u590d\u5236 \u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\u7684\u6570\u636e\u7c7b\u578b\u4e0d\u5339\u914d \u786e\u4fdd\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\uff0c\u4f20\u5165\u7684 dataname \u53c2\u6570\u4e0e\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u4e2d\u7684\u53c2\u6570\u6570\u636e\u7c7b\u578b\u5339\u914d\u3002\u6839\u636e\u9898\u4e3b\u63d0\u4f9b\u7684\u4fe1\u606f\uff0c\u5f53 dataname \u8bbe\u7f6e\u4e3a int \u6574\u578b\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u6b63\u5e38\u6267\u884c\u3002\u8fd9\u8868\u660e\u95ee\u9898\u53ef\u80fd\u51fa\u5728\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6 dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u9519\u8bef\u3002 \u5176\u4ed6\u53ef\u80fd\u7684\u89e3\u51b3\u65b9\u6cd5 \u5982\u679c\u4ee5\u4e0a\u5efa\u8bae\u65e0\u6cd5\u89e3\u51b3\u95ee\u9898\uff0c\u8fd8\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u68c0\u67e5\u5b58\u50a8\u8fc7\u7a0b\u7684\u5b9a\u4e49\u662f\u5426\u6b63\u786e\uff0c\u786e\u4fdd dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u6b63\u786e\u3002 \u68c0\u67e5\u5b58\u50a8\u8fc7\u7a0b\u7684\u8c03\u7528\u8bed\u53e5\uff0c\u786e\u4fdd\u4f20\u5165\u7684 dataname \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u4e0e\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u5339\u914d\u3002 \u5c1d\u8bd5\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u8c03\u8bd5\u5de5\u5177\u6765\u8ddf\u8e2a\u95ee\u9898\u3002 [&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-27182","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27182","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=27182"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27182\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}