我有三个表格,显示在此演示中: sql fiddle demo
这些是预期的条件和结果
您可以在此处查看演示中的activity_id
和region_id
,并将unit_id
设为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没有得到预期的结果。我想要空值作为结果......你可以在演示中查看。
非常感谢帮助。
答案 0 :(得分: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)