我想将catetegory_id
和subCategory_id
合并到一列中。但我不知道如何在灵活的查询中做到这一点。下面的代码就是我想要做的事情
SELECT * FROM
(SELECT
ccr.targetpk as pk
FROM
Categories cc
JOIN Cat2CatRel ccr ON cc.pk = ccr.sourcepk
WHERE cc.p_code = '0106')
UNION SELECT CATE.pk as pk FROM CATEGORIES cate WHERE CATE.p_code = '0106'
我需要灵活的查询,其作用与上述代码相同。
答案 0 :(得分:4)
可以在灵活的搜索查询中进行联合。这是一个像你的例子:
SELECT uniontable.PK FROM
(
{{
SELECT {cc:PK} as PK, {cc:code} AS CODE FROM {Categories AS cc}
WHERE {cc:p_code} LIKE '0106'
}}
UNION ALL
{{
SELECT {ccr:PK} as PK, {ccr:code} AS CODE FROM {Cat2CatRel AS ccr}
WHERE {ccr:p_code} LIKE '0106'
}}
) uniontable
您可以在此处找到有关flex搜索的更多信息:Hybris Wiki