Bcause of Null Value data is not refleting

后端 未结 2 1665
情话喂你
情话喂你 2021-01-24 10:25

I have two tables view_shipment_order_release and order_release_remark. When there is no record in order_release_remark for a given order_release_gid, there is no data shown.

相关标签:
2条回答
  • I can only assume that you actually mean order_release_remark.remark_text - which is called Related_Party in your output.

    If this is indeed the case - there is nothing in this query that explains such behavior.

    However, your query is bases on a view - view_shipment_order_release (at least I hope it's a view). Views are just names for select statements - which means that oracle is combining the query recorded in the view with the select statement you posted. My guess is, that there is something in that view that says that that order_release_remark.remark_text must not be empty. Or may be the records where it's empty do not have a value in order_release_gid?

    Bear in mind, oracle believes that null is not equal null - so if order_release_gid is not present (is null) in two records, joining on this field will not return any rows.

    0 讨论(0)
  • 2021-01-24 10:55

    Use left join instead. left join will not be strict and will still display even if there is no data on related party.

    select distinct 
      vsor.shipment_gid,
      vsor.order_release_gid,
      orem1.remark_text as Related_Party,
      orem2.remark_text as ULTIMATE_CONSIGNEE_TYPE,
      orem3.remark_text as CONSIGNEE_TYPE
    from view_shipment_order_release vsor
    LEFT JOIN  order_release_remark orem1
    ON  orem1.REMARK_QUAL_GID ='GECORP.CONSIGNEE TYPE'
     and orem1.order_release_gid=vsor.order_release_gid
      LEFT JOIN order_release_remark orem2
      ON orem2.REMARK_QUAL_GID ='GECORP.RELATED PARTY'  
      and orem2.order_release_gid=vsor.order_release_gid
      LEFT JOIN order_release_remark orem3 
     ON orem3.REMARK_QUAL_GID ='GECORP.ULTIMATE CONSIGNEE TYPE'
    and orem3.order_release_gid=vsor.order_release_gid
    where vsor.shipment_gid='GECORP.101027274';
    
    0 讨论(0)
提交回复
热议问题