爲了能在查詢時忽略字段大小寫,又不想修改數據表的屬性配置,就在SQL語句中作了修改。結果在alibaba druid 執行時報錯sql
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'ame collate 'utf8mb4_general_ci' f', expect RPAREN, actual LITERAL_CHARS pos 166, line 1, column 147, token LITERAL_CHARS utf8mb4_general_ciapp
這個錯誤在sql的命令行執行沒有問題,可是druid 會解析失敗,緣由是collate用錯了地方,只能用在where的查詢條件裏。ui
select app.id,app.token,app.email,app.retry,app.interval_time,app.user_id,app.update_time,app.create_time,app.name from app inner join user on app.user_id=user.id where app.name collate 'utf8mb4_general_ci' like CONCAT('%',#{name,jdbcType=VARCHAR},'%') or user.department like CONCAT('%',#{name,jdbcType=VARCHAR},'%') order by app.create_time desc,app.name