背景
使用mybatis链接clickhouse做数据库查询操作
想通过mybatis mapper文件创建动态sql查询
在拼接where条件时,通常都会使用 where 1=1 and …
但是发现ckickhouse不认这条语句,在控制台输入sql,进行查询,sql如下
select * from dim.dim_districts where 1=1 and province_code='140000';
发现报错
[2021-05-06 12:17:16] std::exception. Code: 1001, type: pqxx::sql_error, e.what() = ERROR: argument of AND must be type boolean, not type integer
[2021-05-06 12:17:16] LINE 1: ...ist_code", "dist_name" FROM "dim_districts" WHERE 1 AND ("pr...
[2021-05-06 12:17:16] ^
[2021-05-06 12:17:16] (version 21.4.3.21 (official build))
clickhouse版本
21.4.3.21
原因分析
大神解答:
这条语句在clickhouse中不太灵
WHAT ?