{"id":1978,"date":"2023-04-01T10:41:29","date_gmt":"2023-04-01T02:41:29","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1978"},"modified":"2023-04-22T08:29:35","modified_gmt":"2023-04-22T00:29:35","slug":"inconsistent-data-types-between-mysql-parameter-fields-and-db-fields-lead-to-accuracy-issues","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/01\/inconsistent-data-types-between-mysql-parameter-fields-and-db-fields-lead-to-accuracy-issues\/","title":{"rendered":"MySQL\u4f20\u53c2\u5b57\u6bb5\u4e0eDB\u5b57\u6bb5\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4\u5bfc\u81f4\u7cbe\u5ea6\u95ee\u9898\u91c7\u5751\u8bb0\u5f55"},"content":{"rendered":"<p>\u5047\u8bbe<code>t_user<\/code>\u8868\u4e2d\uff0c<code>user_id<\/code>\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u4e3a<code>varchar<\/code><\/p>\n<h2>MySQL\u4f20\u53c2\u5b57\u6bb5\u4e0eDB\u5b57\u6bb5\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4<\/h2>\n<pre><code class=\"language-sql\">select * from t_user where merchant_id = 10086;  \/\/\u53ef\u80fd\u4f1a\u67e5\u51fa\u591a\u6761\u6570\u636e<\/code><\/pre>\n<p><!-- more --><\/p>\n<pre><code class=\"language-sql\">select * from t_user where merchant_id = &#039;10086&#039;;  \/\/\u53ea\u4f1a\u67e5\u51fa\u5355\u6761\u6570\u636e<\/code><\/pre>\n<h2>MyBatis Mapper\u4e0eDB\u5b57\u6bb5\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4<\/h2>\n<p>\u5982\u679cMapper\u67e5\u8be2\u63a5\u53e3\u4f20\u5165<code>userId<\/code>\u7684\u6570\u636e\u7c7b\u578b\u4e3a<code>Long<\/code>\uff0c\u90a3\u4e48\u4f1a\u5bfc\u81f4\u7cbe\u5ea6\u95ee\u9898\uff0c\u67e5\u8be2\u7684\u6570\u636e\u6709\u591a\u6761<\/p>\n<p>\u6b63\u786e\u4f20\u53c2\uff1aMapper\u67e5\u8be2\u63a5\u53e3\u4f20\u5165<code>userId<\/code>\u7684\u6570\u636e\u7c7b\u578b\u5e94\u8be5\u4e3a<code>String<\/code><\/p>\n<pre><code class=\"language-java\">public interface MerchantSiteUserMapper {\n\n    \/\/String queryUserInfo(Long userId);  \/\/\u9519\u8bef\u4f20\u53c2\n    String queryUserInfo(String userId);  \/\/\u6b63\u786e\u4f20\u53c2\n}<\/code><\/pre>\n<pre><code class=\"language-xml\">&lt;select id=&quot;queryUserInfo&quot; resultType=&quot;BaseResultMap&quot;&gt;\n  select\n  &lt;include refid=&quot;Base_Column_List&quot;\/&gt;\n  from t_user where merchant_id = #{userId}\n&lt;\/select&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5047\u8bbet_user\u8868\u4e2d\uff0cuser_id\u5b57\u6bb5\u7684\u6570\u636e\u7c7b\u578b\u4e3avarchar MySQL\u4f20\u53c2\u5b57\u6bb5\u4e0eDB\u5b57\u6bb5\u6570\u636e\u7c7b\u578b\u4e0d\u4e00\u81f4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13],"tags":[],"class_list":["post-1978","post","type-post","status-publish","format-standard","hentry","category-mybatis","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1978"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1978\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}