问答详情
源自:-

使用Mp的条件构造器查询时时遇到mysql关键字怎么办呀

 type 和 condition 是mysql关键字 

提问者:慕九州9160395 2020-01-19 00:33

个回答

  • 老猿
    2020-01-19 09:35:23

    不太明白,你是数据库的表字段使用了关键字吗?如果是的话,前后加单引号转义即可吧。方便的话,把那张表和sql语句发出来,我看看怎么弄。

  • 慕九州9160395
    2020-01-19 19:01:13

    @TableField("`condition`")
    @ApiModelProperty(name = "condition" , value = "经验要求")
    private String condition;
    @TableField("`type`")
    @ApiModelProperty(name = "type" , value = "任职方式")
    private String type;

    老师我用@TablleField注解解决了  

    condition  type 是mysql的关键字

    这是我用条件构造器生成的错误信息和sql 

    Error querying database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition,education,type,address,eid,createtime,state,url,label,content1,content' at line 1

    ### SQL: SELECT  id,jobname,salary,condition,education,type,address,eid,createtime,state,url,label,content1,content2  FROM tb_recruit