示例SQL如下
select * from table_order where state = 1 or type = 2
执行报错
Cause: io.shardingjdbc.core.parsing.parser.exception.SQLParsingUnsupportedException: Not supported token 'OR'
解决思路:分别查出state = 1 和 type= 2 的id集合,然后做 in 操作
-- 1. 查出state = 1的id集合
select id from table_order where state = 1
-- 结果集为 1,2
-- 2. 查出type = 2的id集合
select id from table_order where type = 2
-- 结果集为3,4
-- 3. 两个集合相加后做 in 操作
select * from table_order where id in (1,2,3,4)
这样就把 OR 转化为了 IN 完成数据查询