请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

为什么desc要加``呢

<update id="update">
   update business
   <set>
      <if test="title != null">
         title = #{title},
      </if>
      <if test="subtitle != null">
         subtitle = #{subtitle},
      </if>
      <if test="city != null">
         city = #{city},
      </if>
      <if test="category != null">
         category = #{category},
      </if>
      <if test="imgFileName != null">
         img_file_name = #{imgFileName},
      </if>
      <if test="price != null">
         price = #{price},
      </if>
      <if test="distance != null">
         distance = #{distance},
      </if>
      <if test="desc != null">
        `desc` = #{desc},
      </if>
   </set>
   where id= #{id}
</update>

为什么desc要加``呢

正在回答

2回答

哈哈,好问题,你为什么不试试去掉【`】呢?然后再运行程序,看看会发生什么。

desc在一般关系型数据库中是什么意思?

那么在MySQL中,又是怎么解决的呢?

2 回复 有任何疑惑可以回复我~
  • 提问者 田心枫 #1
    哦哦哦   明白啦
    回复 有任何疑惑可以回复我~ 2017-07-05 17:19:24
  • 提问者 田心枫 #2
    我本来写的不加``的,看报错发现这个desc有问题,加了``就可以了
    回复 有任何疑惑可以回复我~ 2017-07-05 17:21:40
  • 源生活 回复 提问者 田心枫 #3
    问题的根本不在于加还是不加,是要知道为什么。祝学习愉快!
    回复 有任何疑惑可以回复我~ 2017-07-05 17:22:47
假蛙工程师 2018-07-23 21:22:22

因为desc是mysql的关键字,对于这种关键字做列名或者表名的要用  `  ` 这个符号引起来,避免歧义

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信