1、问题描述:
GBase数据库执行多表查询时,where条件里有 in(子查询),报错,错误信息:SQL错误[ErrorCode:1149][SQLState:42000]:(GBA-02SC-1001)The query includes syntax that is not supported by the gcluster. com.gbase.jdbc.exceptions.jdbc4.GBaseSyntaxErrorException:(GBA-02SC-1001)The query includes syntax that is not supported by the gcluster.
2、报错原因:多张表 关联查询时,表的字符集编码不一致导致的报错
3、解决方法:
第一种:修改表的字符编码一致 ,修改为utf8
第二种:使用exists 代替 in
示例
修改前:
SELECT * FROM customers WHERE id IN (SELECT customer_id FROM orders);
修改后:
SELECT * FROM customers c WHERE EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.id);