Home » SQL & PL/SQL » SQL & PL/SQL » Join Unique Tables
Join Unique Tables [message #682161] Wed, 07 October 2020 02:35 Go to next message
selami
Messages: 1
Registered: October 2020
Junior Member
Hi all

I have a view that I use at work.

My goal is:

If "data on row " = 'x' then columns should be fetched from "A table"

If "data on row" = 'Y' then fetch from "B table"

Is that possible in same column at the view query? (plsql)

Problem is that The tables I want to use do not have a common columns

if a =1 then select SAMPLE from sample_table

if a <> 1 then SELECT ANOTHER DIFFRENT from another different unique table


and my queries are very complicated with inner joins

Thanks

[Updated on: Wed, 07 October 2020 02:43]

Report message to a moderator

Re: Join Unique Tables [message #682163 is a reply to message #682161] Wed, 07 October 2020 02:44 Go to previous messageGo to next message
Michel Cadot
Messages: 67545
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
If "data on row " = 'x' then columns should be fetched from "A table"

If "data on row = 'Y' then fetch from "B table"

UNION ALL?

Quote:
Problem is that The tables I want to use do not have a common columns

So what is the purpose to have them in the same view?
You want different columns in the result depending on "a"?


You have to be clearer.
Post a test case (CREATE TABLE statements) and what you actually want from these tables.

[Updated on: Wed, 07 October 2020 02:45]

Report message to a moderator

Re: Join Unique Tables [message #682168 is a reply to message #682161] Wed, 07 October 2020 07:36 Go to previous message
John Watson
Messages: 8426
Registered: January 2010
Location: Global Village
Senior Member
Do you mean something like this -
orclz> select
  2  (case deptno when 10 then (select sal from emp where rownum=1) when 20 then (select losal from salgrade where rownum=1) else null end)
  3  from dept;

(CASEDEPTNOWHEN10THEN(SELECTSALFROMEMPWHEREROWNUM=1)WHEN20THEN(SELECTLOSALFROMSALGRADEWHEREROWNUM=1)ELSENULLEND)
----------------------------------------------------------------------------------------------------------------
                                                                                                             800
                                                                                                             700
Previous Topic: Loop with Dates
Next Topic: OBJECT TYPE Body creation ERROR
Goto Forum:
  


Current Time: Sat Nov 28 22:59:51 CST 2020