1

我在这个演示中有三个表:sql fiddle demo

这些是预期的条件和结果

在此处输入图像描述

在这里,您可以检查此内容activity_idregion_id在演示中获取unit_idAs MEASUREMENT_UNIT_ID

到目前为止我尝试了什么:

select t.entity_id, t.parent_id, t.length,gu.measurement_unit_id
    from tree t
    left join product_autoselect_units u
    on t.parent_id = u.region_id
    or t.parent_id = u.activity_id
    or t.entity_id IN (ACtivity_id)
    left join units gu
    on u.id = gu.unit_id
    WHERE t.entity_id IN (Region_id)

查询显示的演示正在获取此条件和结果

在此处输入图像描述

所以这里activity_id=5753 和region_id=10 没有得到预期的结果。我想要空值作为结果...您可以查看演示。

帮助将不胜感激。

4

1 回答 1

0
i have tried you query on given link in your post

try to put your id for time being like in below query and see the result
select t.entity_id, t.parent_id, t.length,gu.measurement_unit_id
    from tree t
    left join product_autoselect_units u
    on t.parent_id = u.region_id
    or t.parent_id = u.activity_id
    or t.entity_id IN (ACtivity_id)
    left join units gu
    on u.id = gu.unit_id
where t.entity_id in (5742,5753)
  ##WHERE t.entity_id IN (Region_id)
于 2013-05-29T08:26:27.300 回答