Home » SQL & PL/SQL » SQL & PL/SQL » how to write select query
how to write select query [message #291433] Fri, 04 January 2008 03:46 Go to next message
parasuramchekuri
Messages: 32
Registered: March 2007
Location: vishakapatnam
Member
hi all
i have four tables

first table contains one retrive frequency column, value of these columns are 1,2,3

my requirement is by using the above values i can retrive values from different 3 tables
i.e
when retrive frequency value is 1
then we can retrive the values from table1


when retrive frequency value is 2
then we can retrive the values from table2

when retrive frequency value is 3
then we can retrive the values from table3

how can i retrive the values
let me know
Thanks in advance
ram...

Re: how to write select query [message #291437 is a reply to message #291433] Fri, 04 January 2008 03:58 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member

couldn't quite understand your requirement.may be you can use JOIN.can you post a test case.

regards,
Re: how to write select query [message #291438 is a reply to message #291433] Fri, 04 January 2008 03:59 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
select ... from <appropriate table> where ...

Regards
Michel

[Updated on: Fri, 04 January 2008 03:59]

Report message to a moderator

Re: how to write select query [message #291446 is a reply to message #291433] Fri, 04 January 2008 04:31 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member


You may want to do some sort if branching as below (Psuedocode)

   For rec in (SELECT retrive_frequency from Forst_table)
   LOOP
  
     IF rec.retrive_frequency = 1 
     THEN

       SELCT <> 
       INTO  val1
       FROM  TABLE1 ;

     ELSIF rec.retrive_frequency = 2 
     THEN

       SELCT <> 
       INTO  val1
       FROM  TABLE2 ;

     ELSE    

       SELCT <> 
       INTO  val1
       FROM  TABLE3 ;

     END IF;

   END LOOP;

Thumbs Up
Rajuvan.

[Updated on: Fri, 04 January 2008 04:31]

Report message to a moderator

Re: how to write select query [message #291457 is a reply to message #291433] Fri, 04 January 2008 04:57 Go to previous message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
First you need to find a way to join the required tables. Then search for case statement in sql reference manual. You will then be able to do what you want.

HTH

Regards

Raj
Previous Topic: in operator
Next Topic: how to execute oracle procedure with OUT parameter
Goto Forum:
  


Current Time: Sat Dec 10 05:00:31 CST 2016

Total time taken to generate the page: 0.14950 seconds