{"id":6784,"date":"2024-11-14T08:58:57","date_gmt":"2024-11-14T00:58:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6784\/"},"modified":"2024-11-14T08:58:57","modified_gmt":"2024-11-14T00:58:57","slug":"mysql-%e8%a7%a6%e5%8f%91%e5%99%a8%e6%8a%a5-you-have-an-error-in-your-sql-syntax-%e9%94%99%e8%af%af%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6784\/","title":{"rendered":"MySQL \u89e6\u53d1\u5668\u62a5 \u201cYou have an error in your SQL syntax\u201d \u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/172992406013706.jpg\" class=\"aligncenter\" title=\"MySQL \u89e6\u53d1\u5668\u62a5 \u201cYou have an error in your SQL syntax\u201d \u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"MySQL \u89e6\u53d1\u5668\u62a5 \u201cYou have an error in your SQL syntax\u201d \u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u65b0\u5efa\u89e6\u53d1\u5668\u62a5\u8bed\u6cd5\u9519\u8bef<\/strong><\/p>\n<p>\u5728\u521b\u5efa\u89e6\u53d1\u5668\u65f6\uff0c\u67d0\u7528\u6237\u9047\u5230\u4e86\u4ee5\u4e0b\u8bed\u6cd5\u9519\u8bef\u63d0\u793a\uff1a&#8221;you have an error in your sql syntax; check the manual that corresponds to your  server version for the right syntax to use near &#8216;if new.ent_status=&#8217;3&#8217;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then<br \/>&nbsp;&nbsp;&nbsp; insert into sand_grading'&#8221;\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u8be5\u7528\u6237\u68c0\u67e5\u4e86\u89e6\u53d1\u5668\u521b\u5efa\u8bed\u53e5\uff0c\u53d1\u73b0\u5b58\u5728\u8bed\u6cd5\u9519\u8bef\u3002\u5177\u4f53\u800c\u8a00\uff0c\u8bed\u53e5\u4e4b\u95f4\u7684\u7a7a\u683c\u4e0d\u6b63\u786e\u3002\u5220\u9664\u5e76\u91cd\u65b0\u6dfb\u52a0\u7a7a\u683c\u540e\uff0c\u89e6\u53d1\u5668\u521b\u5efa\u6210\u529f\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u66f4\u6b63\u540e\u7684\u89e6\u53d1\u5668\u521b\u5efa\u8bed\u53e5\uff1a<\/p>\n<pre>delimiter $$\ncreate trigger insert_sg after update \non ent_test for each row\nbegin\n    IF NEW.ent_status='3'\n    THEN \n      INSERT INTO sand_grading\n      (ent_number, model_code, test_status) \n      VALUES\n      (old.ENT_NUMBER,'A','1');\n    END IF ;\nend$$<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL \u89e6\u53d1\u5668\u62a5 \u201cYou have an error in your SQL syntax\u201d \u9519\u8bef\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u65b0\u5efa\u89e6\u53d1\u5668\u62a5\u8bed\u6cd5\u9519\u8bef \u5728\u521b\u5efa\u89e6\u53d1\u5668\u65f6\uff0c\u67d0\u7528\u6237\u9047\u5230\u4e86\u4ee5\u4e0b\u8bed\u6cd5\u9519\u8bef\u63d0\u793a\uff1a&#8221;you have an error in your sql syntax; check the manual that corresponds to your server version for the right syntax to use near &#8216;if new.ent_status=&#8217;3&#8217;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; then&nbsp;&nbsp;&nbsp; insert into sand_grading&#8217;&#8221;\u3002 \u4e3a\u4e86\u89e3\u51b3\u8be5\u95ee\u9898\uff0c\u8be5\u7528\u6237\u68c0\u67e5\u4e86\u89e6\u53d1\u5668\u521b\u5efa\u8bed\u53e5\uff0c\u53d1\u73b0\u5b58\u5728\u8bed\u6cd5\u9519\u8bef\u3002\u5177\u4f53\u800c\u8a00\uff0c\u8bed\u53e5\u4e4b\u95f4\u7684\u7a7a\u683c\u4e0d\u6b63\u786e\u3002\u5220\u9664\u5e76\u91cd\u65b0\u6dfb\u52a0\u7a7a\u683c\u540e\uff0c\u89e6\u53d1\u5668\u521b\u5efa\u6210\u529f\u3002 \u4ee5\u4e0b\u662f\u66f4\u6b63\u540e\u7684\u89e6\u53d1\u5668\u521b\u5efa\u8bed\u53e5\uff1a delimiter $$ create trigger insert_sg after update on ent_test for each row begin IF NEW.ent_status=&#8217;3&#8242; THEN INSERT INTO sand_grading (ent_number, model_code, test_status) [&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-6784","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6784","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=6784"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6784\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}