Results 1 to 4 of 4
  1. #1
    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


  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,658
    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.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  3. #3
    Join Date
    Oct 2010
    Posts
    2

    I had arrived at that conclusion

    and I'm working on the select 'select...'
    Thanks...

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,658
    >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.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •