Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i need to do something like this:

Status
Not open for further replies.

raji96

Programmer
Aug 7, 2001
64
US
i need to do something like this:

Select ind from tableind
if ind='F' then
goto tablefemale and get everything
else go to tablemale and get everything
end if

right now iam two select statements and doing an union of them.can this be done by decode?

thanks.
--

 
This might be possible with a decode, but I got to ask. Why have two tables, one for female, one for male? Why not have all data in one database with a field that designates male or female? Would make life a lot easier... Terry M. Hoey
 
Is this the query you have right now?

SELECT *
FROM male_tab
WHERE ind = 'M'
UNION ALL
SELECT *
FROM female_tab
WHERE ind = 'F';

I have read in one of Tom Kyte's tips that this should work for Oracle 8i and up;

SELECT DECODE (ind, 'M', SELECT * FROM male_tab, SELECT * FROM female_tab)
FROM sys.dual;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top