Search code examples
orientdb

unionall function returns duplicate data


i am using unionall function to get the combined results of multiple queries but i get duplicate data , sample example :

select expand($res) let $a = (select from #3:1) , $b = (select from #3:1) , $res = unionall($a,$b)

i get duplicate data ,

even tried by querying rid , but still same result

select $res let $a = (select rid from #3:1) , $b = (select rid from #3:1) ,$res = unionall($a,$b)

how do i get unique values ?


Solution

  • select distinct(@this)
    from (select expand($u) as res
          from (select $u 
                let $a = (select from #3:1),
                    $b = (select from #3:1),
                    $u = unionall($a,$b)) )
    

    Note that "select rid from #3:1" is quite different from "select @rid from #3:1", which in turn is different from "select from #3:1".