普通sql语句:
SELECT REC_ID,ORDER_UPDATE_RULE,ACTIVITY_ID FROM PLT_ACTIVITY_INFO
WHERE ((ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2 )
AND TENANT_ID = 'uni076'
AND ACTIVITY_ID = '112202'
AND ACTIVITY_STATUS = '1'
) ORDER BYLAST_ORDER_CREATE_TIME DESC
在mycat库直接执行没有问题:
程序执行报错:
### Error querying database. Cause: java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME
### The error may exist in com/bonc/busi/orderschedule/mapper/OrderMapper.java (best guess)
### The error may involve com.bonc.busi.orderschedule.mapper.OrderMapper.selectUpdateRuleByActivity-Inline
### The error occurred while setting parameters ### SQL: SELECT REC_ID,ACTIVITY_ID,ORDER_UPDATE_RULE FROM PLT_ACTIVITY_INFO WHERE ( (ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2) AND TENANT_ID='uni076' AND ACTIVITY_ID = '112202' AND ACTIVITY_STATUS='1' ) ORDER BY LAST_ORDER_CREATE_TIME DESC
### Cause: java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME ; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1105]; java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME; nested exception is java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause should be in the selected column list!LAST_ORDER_CREATE_TIME
从错误中发现将LAST_ORDER_CREATE_TIME加在查询字段中 ,即:
SELECT REC_ID,ORDER_UPDATE_RULE,ACTIVITY_ID,LAST_ORDER_CREATE_TIME
FROM PLT_ACTIVITY_INFO
WHERE ((ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2 )
AND TENANT_ID = 'uni076'
AND ACTIVITY_ID = '112202'
AND ACTIVITY_STATUS = '1'
) ORDER BY LAST_ORDER_CREATE_TIME DESC
此时执行正常,结果如下:
版权声明:本文为博主原创文章,转载请注明本页地址。https://blog.csdn.net/l1994m/article/details/83348852