sql - Alternative for union in Oracle -


is there alternate way fetch following data without using union?

select a.name,a.age,b.address,c.phoneno table1 a,table2 b,table3 c a.pkid = b.fkid , b.pkid = c.fkid union select a.name,a.age,b.address,c.phoneno table4 a,table5 b,table3 c a.pkid = b.fkid , b.pkid = c.fkid 

i using in hibernate , unfortunately hibernate doesnt support union. wondering if there other way achieve else ill have write in procedure , save data in temp table , fire sql read data temp table

there alternative union, not pretty:

select distinct coalesce(x1.name, x2.name) name,        coalesce(x1.age, x2.age) age,        coalesce(x1.address, x2.address) age,        coalesce(x1.phoneno, x2.phoneno) age, (select a.name, a.age, b.address, c.phoneno       table1 join            table2 b            on a.pkid = b.fkid join            table3 c             on b.pkid = c.fkid      ) x1 full outer join      (select a.name, a.age, b.address, c.phoneno       table4 join            table5 b            on a.pkid = b.fkid join            table3 c             on b.pkid = c.fkid      ) x2      on 1 = 0;  -- false 

i can't imagine why want express union this. highly recommend, though, start using proper, explicit join syntax.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -