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 > selecting 'ID' from multiple tables where ID like

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Oct 2010
Posts: 2
selecting 'ID' from multiple tables where ID like

i have 50+ schemas with similar structures with 300 tables each containing a column named 'ID'. I need to find only those columns having a value beginning with a common string...which could be 'A' through 'ZZ'
logged into the schema,
select table_name from user_tab_columns where column_name='ID';

gives me the tables I need. so i tried

select ID from (select table_name from user_tab_columns where column_name='ID');

thinking that i could merely add a where clause to get what i wanted, but I received:
ERROR at line 1:
ORA-00904: "ID": invalid identifier

Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,495
SQL does not support/allow what you were attempting to do.
one way or another, 300 different SELECT statements must be used; one statement for each table.
utilize EXECUTE IMMEDIATE
or write SQL to construct the unique SELECT statements.
__________________
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.
Don't say, show. Don't promise, prove.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Oct 2010
Posts: 2
I had arrived at that conclusion

and I'm working on the select 'select...'
Thanks...
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,495
>and I'm working on the select 'select...'
YES!
It is somewhat brute force, but 100% effective.
I do it regularly.
__________________
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.
Don't say, show. Don't promise, prove.
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