APIJSON icon indicating copy to clipboard operation
APIJSON copied to clipboard

Join时需要调用函数,如何写???

Open mrcaobin opened this issue 4 years ago • 2 comments

有两张表 A ,B 函数func(col1,col2)返回布尔类型

select t1.* from A t1 left join B t2 on func(t1.col1,t2.col2)=true

请问这种怎么写?

mrcaobin avatar Jun 28 '21 06:06 mrcaobin

目前不支持,自己加个接口实现。 当然这个需求其实可以把条件放到 WHERE/HAVING 中

可以提个新增该功能的建议 https://github.com/Tencent/APIJSON/issues/37

TommyLemon avatar Aug 30 '21 14:08 TommyLemon

现在好像可以通过 JOIN 指定条件 + @raw 实现,因为 ON 上已经支持复杂条件,我后面再看看 image

如果 func 是指 json_contains,那现在已经可以了

"col1<>@":"/T2/col2" // ON json_contains(T1.col1, cast(T2.col2 AS CHAR))

"col1{}@":"/T2/col2" // ON json_contains(T2.col2, cast(T1.col1 AS CHAR))

TommyLemon avatar Mar 15 '22 15:03 TommyLemon