以前在mysql5.7上执行如下sql语句没有问题
SELECT DISTINCT u.*,c.content userCategory FROM m_user u LEFT JOIN m_category c ON u.user_category=c.category_id LEFT JOIN m_user_role mr ON u.user_id=mr.user_id WHERE 1=1 AND u.user_status=0 ORDER BY u.createtime DESC LIMIT 10
使用mycat 1.6.6.1后执行上面的sql语句报错如下:
1 queries executed, 0 success, 1 errors, 0 warnings
查询:SELECT DISTINCT u.*,c.content userCategory FROM m_user u LEFT JOIN m_category c ON u.user_category=c.category_id LEFT JOIN m_use...
错误代码: 1064
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 '*, c.content
ORDER BY u.createtime DESC
LIMIT 10' at line 5
执行耗时 : 0 sec
传送时间 : 0 sec
总耗时 : 0.008 sec
后来把mycat上执行的语句改为如下语句(把 distinct后的 * 号改为u表的每个字段)执行成功:
SELECT DISTINCT u.user_id,u.user_name,u.user_pwd,u.user_realname,u.user_email,u.mobile_phone,u.office_phone,u.user_category,u.user_subcategory,u.user_status,u.createtime,u.updatetime,u.createuser,u.user_ip,u.user_odm_id,c.content userCategory FROM m_user u LEFT JOIN m_category c ON u.user_category=c.category_id LEFT JOIN m_user_role mr ON u.user_id=mr.user_id WHERE 1=1 AND u.user_status=0 ORDER BY u.createtime DESC LIMIT 10