{"id":27524,"date":"2024-11-24T12:01:57","date_gmt":"2024-11-24T04:01:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27524\/"},"modified":"2024-11-24T12:01:57","modified_gmt":"2024-11-24T04:01:57","slug":"mysql-%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8b%e4%bc%a0%e5%85%a5%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%8f%82%e6%95%b0%e6%8a%a5%e9%94%99%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bc%a0%e5%85%a5%e5%ad%97%e7%ac%a6-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27524\/","title":{"rendered":"MySQL \u5b58\u50a8\u8fc7\u7a0b\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u4f20\u5165\u5b57\u7b26\u4e32\u4f1a\u62a5\u9519\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173128536493040.jpg\" class=\"aligncenter\" title=\"MySQL \u5b58\u50a8\u8fc7\u7a0b\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u4f20\u5165\u5b57\u7b26\u4e32\u4f1a\u62a5\u9519\uff1f\u63d2\u56fe\" alt=\"MySQL \u5b58\u50a8\u8fc7\u7a0b\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u4f20\u5165\u5b57\u7b26\u4e32\u4f1a\u62a5\u9519\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570\u4f20\u5165\u5b57\u7b26\u4e32\u62a5\u9519<\/strong><\/p>\n<p>\u5728\u521b\u5efa\u4e86\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684 mysql \u5b58\u50a8\u8fc7\u7a0b\u540e\uff0c\u4f60\u4f1a\u9047\u5230\u4e00\u4e2a\u9519\u8bef\uff1a<\/p>\n<pre>create procedure mypo02(in dataname varchar(10))\n  begin\n  if dataname is null or dataname = \"\" then\n      select * from ssd;\n  else\n      select * from ssd where ename like concat('%',dataname,'%');\n  end if;\nend;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u9519\u8bef\u4fe1\u606f\u4e3a\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>\u95ee\u9898\u5728\u4e8e\uff1a\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\u4f20\u5165\u7684 dataname \u53c2\u6570\u7c7b\u578b\u4e0d\u5339\u914d\u3002<\/p>\n<p>\u5f53 dataname \u53c2\u6570\u4e3a\u6574\u578b\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u4f46\u5f53 dataname \u53c2\u6570\u4e3a\u5b57\u7b26\u4e32\u65f6\uff0c\u7531\u4e8e where \u5b50\u53e5\u4e2d\u7684\u5b57\u6bb5\u7c7b\u578b\u4e3a\u6574\u578b\uff0c\u5c31\u4f1a\u5bfc\u81f4\u9519\u8bef\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\u4f20\u5165\u7684\u53c2\u6570\u7c7b\u578b\u4e0e\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u4e2d\u6307\u5b9a\u7684\u7c7b\u578b\u76f8\u5339\u914d\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u4f60\u9700\u8981\u5c06 dataname \u6539\u4e3a\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>call mypo02('\u738b\u5c0f\u674e')<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u8bf7\u63d0\u4f9b\u66f4\u8be6\u7ec6\u7684\u9519\u8bef\u4fe1\u606f\u6216\u4ee3\u7801\u7247\u6bb5\uff0c\u4ee5\u4fbf\u8fdb\u4e00\u6b65\u5206\u6790\u89e3\u51b3\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u5b58\u50a8\u8fc7\u7a0b\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\u62a5\u9519\uff1a\u4f20\u5165\u5b57\u7b26\u4e32\u4f1a\u62a5\u9519\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\u4f20\u5165\u5b57\u7b26\u4e32\u62a5\u9519 \u5728\u521b\u5efa\u4e86\u4e00\u4e2a\u5982\u4e0b\u6240\u793a\u7684 mysql \u5b58\u50a8\u8fc7\u7a0b\u540e\uff0c\u4f60\u4f1a\u9047\u5230\u4e00\u4e2a\u9519\u8bef\uff1a create procedure mypo02(in dataname varchar(10)) begin if dataname is null or dataname = &#8220;&#8221; then select * from ssd; else select * from ssd where ename like concat(&#8216;%&#8217;,dataname,&#8217;%&#8217;); end if; end; \u767b\u5f55\u540e\u590d\u5236 \u9519\u8bef\u4fe1\u606f\u4e3a\uff1a procedure execution failed 1054 &#8211; unknown column &#8216;\u738b\u5c0f\u674e&#8217; in &#8216;field list&#8217; \u767b\u5f55\u540e\u590d\u5236 \u95ee\u9898\u5728\u4e8e\uff1a\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u65f6\u4f20\u5165\u7684 dataname \u53c2\u6570\u7c7b\u578b\u4e0d\u5339\u914d\u3002 \u5f53 dataname \u53c2\u6570\u4e3a\u6574\u578b\u65f6\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002\u4f46\u5f53 [&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-27524","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27524","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=27524"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27524\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}