Home » SQL & PL/SQL » SQL & PL/SQL » table join
table join [message #201229] Fri, 03 November 2006 03:56 Go to next message
sujeethbala
Messages: 25
Registered: October 2006
Location: INDIA
Junior Member
hi
i have 2 tables
transfer
---------
transferno
from_branch_code (Fk)
to_branch_code (fk)

Branch
-------
Branch_code (pk)
Branch_name

this is my query
select TR.Transferno,B.From_Branch,T.To_Branch from Transfer TR,(Select Branch_name
From_branch,branch_code  from branch) B,(Select Branch_name To_branch,branch_code from
branch) T where TR.From_Branch_code=B.Branch_code and TR.To_branch_code=T.Branch_code;


its working fine. please suggest me is it the proper one, or is there any other type of query which will increse the performence.

regards
sujith
Re: table join [message #201235 is a reply to message #201229] Fri, 03 November 2006 04:07 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I'd remove the inline views, and just use the branch table twice, like this
select TR.Transferno
      ,B.Branch_name from_branch
      ,T.Branch_name to_branch
from   transfer TR
      ,branch B
      ,branch T
where TR.From_Branch_code=B.Branch_code 
and   TR.To_branch_code=T.Branch_code;


Re: table join [message #201239 is a reply to message #201235] Fri, 03 November 2006 04:17 Go to previous message
sujeethbala
Messages: 25
Registered: October 2006
Location: INDIA
Junior Member
thanks Cool
its simple.
Previous Topic: Testing whether rows exist from multiple tables with one PL/SQL-SQL context switch?
Next Topic: managing errors from script
Goto Forum:
  


Current Time: Sat Dec 03 12:13:40 CST 2016

Total time taken to generate the page: 0.11684 seconds