If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Combining 3 scripts

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-10, 13:14
BradH BradH is offline
Registered User
 
Join Date: Feb 2010
Posts: 2
Combining 3 scripts

I use 3 separate scripts to determine a users USERID and ACCESS.

There are 3 tables, all with only a USERID and ACCESS field. Name the Tables A, B, C.

Problem is, nobody will have all 3, sometimes 2, but mostly only 1. I tried to join the scripts, but they would come up blank...I assume because of the absence of data on 1 or 2 of the tables.

Is there a way to run a merged script that would show which ACCESS members have? The USERID's would match on all 3 tables.

Here is what I tried:

select * from A, B, C where A.OPRID=B.OPRID and A.OPRID=C.OPRID AND A.OPRID = '&USERID';

Please be kind, I am a novice, and I tried finding this on here, but couldn't find anything that made any sense to me......
Reply With Quote
  #2 (permalink)  
Old 02-08-10, 13:25
n_i n_i is online now
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
select * from A where A.OPRID = '&USERID'
union
select * from B where B.OPRID = '&USERID'
...
Reply With Quote
  #3 (permalink)  
Old 02-08-10, 15:01
BradH BradH is offline
Registered User
 
Join Date: Feb 2010
Posts: 2
Thanks Nick, that worked.

Now, is there a way to tell which table it was drawn from?

All 3 tables are named for their type access, so the only way I know what type access they have is to know which table it was drawn from.

Hope that makes sense.....
Reply With Quote
  #4 (permalink)  
Old 02-08-10, 15:07
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,407
>All 3 tables are named for their type access
Do you mean to say the access types are A, B, & C?
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #5 (permalink)  
Old 02-08-10, 15:36
n_i n_i is online now
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,448
Quote:
Originally Posted by BradH View Post
Now, is there a way to tell which table it was drawn from?
select 'Type A', A.* from A where A.OPRID = '&USERID'
...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On