SELECT from multiple schemas
438676Feb 18 2005 — edited Feb 21 2005I have an Oracle database with two schemas in it, there's a table in each schema and two colums in each. with the exception of the schema name they're identical.
Schemas: rate1, rate2
Table: rate_details
Columns: rate_file, rate_live
Each table will only ever have one row in it. The rate_file column will contain a filename and the rate_live will contain either a Y or N.
Only one of the schemas will have it's rate_live column set to Y at any one time.
I want to write an SQL statement that will tell me what the value of rate_file is by providing the rate_live value.
The statement I have is as follows:
SELECT r1.rate_file, r2.rate_file
FROM rate1.rate_details r1, rate2.rate_details r2
WHERE rate_live = 'Y'
My problem here is that rate_live is ambiguous as it's in both schemas, so it wants me to tell it which schema to look to.
Is there a way around this? Ultimately, if my data was as follows, the only output I'd want is date_250205:
Schema (rate1)
rate_file is date_180205
rate_live is N
Schema (rate2)
rate_file is date_250205
rate_live is Y