Open DuaneDu opened 7 years ago
也可以将复杂sql放到存储过程吧
这个sql是动态生成的。。
30 < a01101 < 40
这种语法合法?
貌似合法...
''' expr: boolean_primary
boolean_primary: boolean_primary comparison_operator predicate | predicate
comparison_operator: = | >= | > | <= | < | <> | !=
'''
@wenshao 这种写法在mysql里面是合法的。上面的语句在mysql里面可以直接执行的
数据库为mysql 5.7 druid版本为 1.0.28 以下sql解析错误 Sql: SELECT '性别 = 1 ' as type , IFNULL(count( if ( a01101 < 20 ,1 ,0)),0) as '年龄 < 20 ' , IFNULL(count( if ( 20 < a01101 < 30 ,1 ,0)),0) as ' 20 < 年龄 < 30 ' , IFNULL(count( if ( 30 < a01101 < 40,1 ,0)),0) as ' 30 < 年龄 < 40 ' from t_employees where a0107 = 1 and a0191 = 1 UNION SELECT ' 性别 = 2' as type , IFNULL(count( if ( a01101 < 20 ,1 ,0)),0) as '年龄 < 20 ' , IFNULL(count( if ( 20 < a01101 < 30 ,1 ,0)),0) as ' 20 < 年龄 < 30 ' , IFNULL(count( if ( 30 < a01101 < 40,1 ,0)),0) as ' 30 < 年龄 < 40 ' from t_employees where a0107 = 2 and a0191 = 1
错误堆栈信息为
com.alibaba.druid.sql.parser.ParserException: syntax error, expect RPAREN, actual LT a01101 at com.alibaba.druid.sql.parser.SQLExprParser.accept(SQLExprParser.java:1827) at com.alibaba.druid.sql.parser.SQLExprParser.methodRest(SQLExprParser.java:821) at com.alibaba.druid.sql.parser.SQLExprParser.primaryRest(SQLExprParser.java:771) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primaryRest(MySqlExprParser.java:486) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:603) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:172) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:85) at com.alibaba.druid.sql.parser.SQLExprParser.exprList(SQLExprParser.java:925) at com.alibaba.druid.sql.parser.SQLExprParser.parseAggregateExpr(SQLExprParser.java:1067) at com.alibaba.druid.sql.parser.SQLExprParser.methodRest(SQLExprParser.java:803) at com.alibaba.druid.sql.parser.SQLExprParser.primaryRest(SQLExprParser.java:771) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primaryRest(MySqlExprParser.java:486) at com.alibaba.druid.sql.parser.SQLExprParser.primary(SQLExprParser.java:603) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primary(MySqlExprParser.java:172) at com.alibaba.druid.sql.parser.SQLExprParser.expr(SQLExprParser.java:85) at com.alibaba.druid.sql.parser.SQLExprParser.exprList(SQLExprParser.java:925) at com.alibaba.druid.sql.parser.SQLExprParser.methodRest(SQLExprParser.java:812) at com.alibaba.druid.sql.parser.SQLExprParser.primaryRest(SQLExprParser.java:771) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlExprParser.primaryRest(MySqlExprParser.java:486) at com.alibaba.druid.sql.parser.SQLExprParser.parseSelectItem(SQLExprParser.java:2149) at com.alibaba.druid.sql.parser.SQLSelectParser.parseSelectList(SQLSelectParser.java:373) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlSelectParser.query(MySqlSelectParser.java:152) at com.alibaba.druid.sql.parser.SQLSelectParser.select(SQLSelectParser.java:59) at com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser.parseSelect(MySqlStatementParser.java:247) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:114) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:79) at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:74) at com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils.parameterize(ParameterizedOutputVisitorUtils.java:50) at com.alibaba.druid.filter.stat.StatFilter.mergeSql(StatFilter.java:145) at com.alibaba.druid.filter.stat.StatFilter.createSqlStat(StatFilter.java:629) at com.alibaba.druid.filter.stat.StatFilter.statementPrepareAfter(StatFilter.java:305) at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:124) at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:448) at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342) at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:331)
请帮忙看看 应该是parser不支持 类似于 1<column<10 这样的语法