SELECT from multiple schema's

How do I select/insert/update/delete from multiple schema's.
Tried:
SELECT * FROM schema1.table1, schema2.table2
WHERE schema1.table1.column1 = schema2.table2.column2;
Errored......

Hello
you need to use an alias for each table
tylerd@UAT51> select dual.dummy from dual, dual
  2  /
select dual.dummy from dual, dual
ERROR at line 1:
ORA-00918: column ambiguously defined
tylerd@UAT51> select dual_1.dummy,dual_2.dummy from dual dual_1, dual dual_2
  2  /
D D
X X
1 row selected.

Similar Messages

  • How do I select from multiple schema's

    How do I select from multiple schema's
    Tried:
    SELECT * FROM schema1.table1, schema2.table2
    WHERE schema1.table1.column1 = schema2.table2.column2;
    Errored......

    Thanks
    We finally got in touch with our DBA and he said the same thing.
    SELECT t1.*,
    t2.*
    FROM schema1.table1 t1,
    schema2.table2 t2
    WHERE t1.column1 = t2.column2;
    I'll try it afther I finish a task my boss just gave me.
    BRB then.

  • SELECT from multiple schemas

    I 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

    Richard:
    I don't think that there is a more efficient way to do this query. Given that "Each table will only ever have one row in it", Oracle will always full-scan both tables anyway. In either of my queries, Oracle would essentially, full scan rate1.rate_details, then full scan rate2.rate_detail and concatenate that to the first resultset. The combined rows would then be filtered (i.e. Inspect each row for the value of rate_live) to find the one(s) matching the criteria.
    I don't really see this problem as being a grouping problem at all, and any solution using GROUP BY would only add at least one sort for the group by.
    Generally speaking, I see UNION [ALL] queries as answering a different set of questions than grouping queries, although the tw can be, and often are, combined. I would be interested to see where you saw the comments about UNION ALL being replaced by Grouping Sets.
    John

  • Selecting from multiple tables, into one internal table

    Hi,
    What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
    Thanks,
    John
    Points will be rewarded and all responses will be highly appreciated.

    I have simple example :
    First one - Join 5 tables
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 4 or 5 tables join.
    get run time field f2.
    f3 = f2 - f1 ( Total time).
    Second one - joins 3 table and use for all entries
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 3 tables join and use for all entries
    get run time field f2.
    f3 = f2 - f1. ( Total time )
    Finally you can have time diffrence between the both sql statement.

  • How to select from multiple addresses of account in IC Web Client

    Hi all,
    We are implementing a B2C scenario for IC Web Client. We have customers with multiple addresses. However, when we search the acount, only standard address comes to screen.  We want to be able select the related address, and then confirm the acount with that address.
    Is there any way to customize the Web Client in order to be able to select from multiple addresses of the acount?
    Thanks in advance.
    Edited by: Danisman Danisman on Aug 31, 2010 2:52 PM

    Thanks for the answer. Yes, we are using 7.0 but in the account identification screen, there is no personalize button ( I assume you are suggesting adding an addres block by using that button, right?).
    We checked the necessary customizing : there is an entry for fucntional profile PERSONALIZATION : ALL_ENABLED.
    Should we do something else to show the button?
    Thanks again.

  • Select from Multiple tables

    Hi,
    I am doing select from multiple tabels (2) in one SQL query.
    How to get the result as it says.. Column name is incorrect ?
    thanks,
    -raj

    treat the resultset as noraml. You get it in sequence as you have specified the column names. You use rs.getXXX(index) instead of columnname

  • Sample PHP Service selecting from multiple tables

    Hi all!
    I have the following challange:
    How do I properly set up my PHP-service to insert, select, update and delete values from multiple tables?
    So far, the standard templates generated by Flash Builder is based on a single table.
    Example: I have 2 tables: [person] and [school]
    [person] has [person_id, first_name, last_name, birthdate]
    [school] has [school_id, person_id, school_name, city]
    One [person] can have multiple [schools]
    How should I define the selectByID function in PHP to be able to have
    First name: [TextInput /]
    Last name: [TextInput /]
    Birthdate: [DateField /]
    Schools:
    [TabBar: School1, School2, School3 /]
    [ViewStack1]
    School name: [TextInput /]
    Location name: [TextInput /]
    [/ViewStack1]]
    [ViewStack2]
    School name: [TextInput /]
    Location name: [TextInput /]
    [/ViewStack2]]
    [ViewStack3]
    School name: [TextInput /]
    Location name: [TextInput /]
    [/ViewStack3]]
    And even more interesting: How do I update all these fields back to the database?

    First, the relationship between school and person is many-to-many NOT one-to-many -- you will need to add a junction table.
    From the form you have given I would handle insertions like this:
    loop through all the schools and see if the school already exist in the DB. If so, then store the school_id. If not, then create a new record and store the id. You should have an array collection of store_ids by the end of the loop
    Check whether the student exists w/in the DB. If so, then you might consider aborting the operation or you could opt to do an update. If the student doesn't exist, then create a new student record and store the new student_id (mysql::insert_id)
    Loop through the school_id array and add new student_id/school_id records into the junction table.
    Retrieving records is much simpler -- it's just a join on the tables i.e. "SELECT * FROM student INNER JOIN school_student ON student.student_id = school_student.student_id INNER JOIN schools ON school_student.school_id = school.school_id WHERE student.first_name = 'John' AND student.last_name = 'Doe' (assuming there aren't more than one John Does of course!).
    - e

  • Select from multiple tables without join statement

    Hey Gurus,
    I would like to make a select from a multiple tables to check if there is any reference to my data. I would like to do it with some elegancy, but I don't know how.
    Is in abap sql possible to do it only with the select statement?
    Or I was also think about a solution that I should fill some data structure with all of the tables which I want to select from and then just loop that data structure and do the select seperately from all of the tables. I just need to check if it founds some results, so no need to store it. If this solution would be fine what data structure should I use?
    Or can tell me what would be the best for this?
    My code for select from one table, which I want to make for multiple tables:
    SELECT SINGLE id_kniznice FROM zbr_t_autori INTO wa_id
           WHERE id_kniznice EQ ls_extract-zview-id_kniznice.
         IF sy-dbcnt > 0.
           MESSAGE i000(zbr_msgc_lib).
           ls_extract-flags-vim_mark = '*'.
           MODIFY extract FROM ls_extract.
    ENDIF.   
    Thank you for any posts.
    Regards,
    Robert

    And there we go again...
    Read this topic:
    For All Entries is NOT better than INNER JOIN in most cases
    And this one:
    inner join vs for all entries
    Also that one:
    Re: LOOP AT vs INNER JOIN
    JOINs are really better than for all entries in most cases. Problem is people tend to ignore basic things like using pks or indexes while making them.

  • Selection from Another schema by default without schema name qualifier.

    Hi
    Oracle10g release 2, LinuxOS
    i want my schema (User_1) to always select,insert, update, delete the objects from another schema (User_2) without passing full schema qualifier every time whenever i don't pass any schema name explicitly.
    i.e. if i pass the following guerry
    select * from table_a;
    the table of user User_2.table_a (User_2.table_a) will be queried by default instead of table (User_1.table_a)
    and the same implementation is also required in Functions , procedures, sequences etc.
    Wishes

    Three relatively easy options
    1) Create private synonyms in User_1's schema for each object in User_2's schema, i.e.
    CREATE SYNONYM table_a
       FOR user_2.table_a2) Create public synonyms for each object in User_2's schema. This will make it possible for all users to query user_2's objects without specifying the schema name
    CREATE PUBLIC SYNONYM table_a
       FOR user_2.table_a3) Change the current schema for the session (potentially in a login trigger)
    ALTER SESSION SET current_schema = USER_2There are other options that are a bit more complicated like using enterprise users with shared schemas. But most people are perfectly happy with one of these three.
    Justin

  • Selecting from another schema

    If I want to select table from another schema, I have to type
    select * from [username].table_name.
    What can I do inorder not to write shema name all the time.
    for instance:
    instead of writing
    select * from [username].table_name.
    select * from table_name.

    create synonym for the object in other schema:
    create synonym <syn-name> for schema.tablename;
    then use syn-name in place of schema.tablename in ur query
    like
    select * from syn-name;

  • Selecting from multiple sqlserver databases with HS

    I have setup HS from oracle 8.1.7 to sqlserver 7.0 for one database and it works fine. I have about six databases on the same NT server and will like to select from the various databases, the tables I need to update Oracle. I have edited the odbc.ini file to add the other sqlserver database entries. I have also updated the inithsmsql.ora file to add multiple entries for the other databases. When I select from distinct tables in the databases it works fine. But if I have the same tables in database A,B and C and want to select column from table A in database A, I get the result for table A in database B. Is there a way to select from identical tables from different databases and get the result for the table and database that is needed.
    ie select column from data_souce_name.table_name@hsmsql. Is there a syntax or configuration for that.
    Thanks

    Vira I am actually making multiple entries of these parameters in the inithsmsql.ora file. The first data source is test then I will copy it and edit it for another data source test1 etc. Even making one init.ora file in the hs/admin directory for the databases how will the system know from which database to query if one table exist in more than one database. Also even adding multiple listeners for the different sids won't help as the program= will be same for all. ? multiple tnsnames entries?
    HS_FDS_CONNECT_INFO = test
    HS_FDS_TRACE_LEVEL = 2
    HS_FDS_TRACE_FILE_NAME = test5.trc
    HS_FDS_SHAREABLE_NAME = /dbdata/odbc/lib/libodbc.so

  • Is selecting from a view more efficient than selecting from multiple tables

    Hi heres the problem
    Lets say i created a view from 2 tables (person and info). both have a ID column
    create view table_view (age,name,status,id) as
    select a.age, a.name, b.status, b.id
    from person a, info.b
    where a.id=b.idif i want to select a given range of values from these 2 tables which of the following queries would be more effective.
    select a.age, a.name, b.status, b.id
    from person a, info.b
    where a.id=b.id
    and a.id <1000
    select age, name, status, id
    from table_view
    where  id <1000

    Bear in mind that this concept of views storing the SQL text is something relative to Oracle databases and not necessarily other RDBMS products. For example, Ingres databases create "views" as tables of data on the database and therefore there is a difference between selecting from the view and selecting from the base tables.
    Oracle also has "materialized views" which differ from normal "views" because they are actually created, effectively, as tables of data and will not use the indexes of the base tables.
    In Oracle, you cannot create indexes against "views" but you can create indexes against "materialized views".

  • Select from multiple entries in table cell.

    Hi All,
    I'm having issues when trying to do a simple select from an access database:
    <CFQUERY NAME="GetAllByMonth" DATASOURCE="dsn">
    SELECT * FROM table WHERE  strMonth = '#url.strMonth#' AND strDisplay = Yes
    order by strOrder_id
    </CFQUERY>
    Table cells in rows contain coma separated values:
    January, February, March, April, May, June, October, November, December
    Unfortunately the query returns no values. I've tried changing the "=" with "like", "contains" but with no results.
    Difficult to know what to search for so any help gratefully recieved.
    Ta
    Trevor

    Here is an absolutely crazy "hack" that I once used when dealing with a database like that.  It had hundreds of thousands of rows with comma separated values that for various legacy could not be changed.
    So one day I did this ...  SELECT DISTINCT column_from_purgatory FROM table_from_hell.
    Much to my surprise, there were less than a hundred DISTINCT values in that column.  (They were, fortunately, reasonably-sized VARCHARs.)
    So I built a table of those values, then created a separate table into which I could put each of the comma-separated parts, and then wrote a small (Perl) script to populate the two.  For example, a row containing "January, March, April" would be linked to three rows containing one month-name each.
    Now, as long as I had a way to be sure that this pair of lookup-tables was always complete (which was slightly problematic), I had something that I could actually JOIN to.  It wasn't pretty ... in fact, it was butt-ugly ... but it saved a tremendous amount of processing time for this application.

  • Select from multiple fileds

    Hi Gurus
    I need select datas from a table where i need to check ten fileds what all having this two values 1,2.For example if there alco1 to alco10 these are names of fileds i need to select the data whcih all the fileds having 1 or 2 in these ten fileds.
    Can u please give me help regading this
    Thanks & Regards
    Manikandan K.

    Your explanation of what you want is poor.
    Do you mean this?
    select *
    from table_name
    where 1 in (alco1,alco2,alco3,alco4,alco5,alco6,alco7,alco8,alco9,alco10)
    and 2 in (alco1,alco2,alco3,alco4,alco5,alco6,alco7,alco8,alco9,alco10)

  • Select From Multiple CTE?

    I was wondering if it is possible to create 2 - 3 CTE statements, and then run ONE select statement that would return the results from all 3 statements?  Something like (I am just throwing this together for example, please excuse any syntax issue)
    ;With CTE AS (Select Count(numSold) As TotalSold, 'Total Sold' As Description
    FROM tblSaleInfo
    Where sold Is not null)
    Select * from cte
    ;With CTE1 As (Select Count(employeeName) As TotalEmployee, 'Total Employee' As Description
    From tblEmployeeInfo
    Where Active is not null)
    Select * from cte1
    --Could you possibly select * from both CTE statements to return one dataset, maybe something like
    Select * from cte
    UNION ALL
    Select * from cte1

    Yes, but the correct way to do it is
    ;With CTE AS (Select Count(numSold) As TotalSold, 'Total Sold' As Description
    FROM tblSaleInfo
    Where sold Is not null),
    CTE1 As (Select Count(employeeName) As TotalEmployee, 'Total Employee' As Description
    From tblEmployeeInfo
    Where Active is not null)
    Select * from cte
    UNION ALL
    Select * from cte1
    You want to declare all the CTE's (separated by commas), followed by the query that uses the CTEs.
    Tom
    Thank you, I was having a brainstorming moment and not in front of SQL Server at the moment so I couldn't test my syntax.  Thank you!

Maybe you are looking for

  • UPGRADE/SWITCH: START OF PHASE STARTSAP_TRANS ERROR

    hi My upgrade is failing to start the sapsystem at the upgrade/switch phase SYSTEM START failed, code -2              -2: the test rfc did not work.              Try to log on to the system with user DDIC. i have tried to log in as ddic but its not r

  • HT1218 How do I troubleshoot this: Time Capsule cannot complete the backup. The backup disk image "/Volumes/Data/ MacBook Pro.sparsebundle" is already in use.

    This is the second time I've encountered this issue with Time Capsule using Time Machine automatic backup. I haven't found the following specific error message in the list of troubleshooting issues: "Time Capsule cannot complete the backup. The backu

  • A configuration problem with saloris8

    I installed Solaris8 for intel on my pc. When I logoned to the system, it told me that some configurations of the windows system are incomplete or incorrect. I tried doing the confuguration test with kdmconfig,but it showed the message"Out the ranage

  • Fade Out_Not Working..??

    I am editing with FCP 6.02, in 720P HDV. I have not had this problem throughout my whole project. But all of a sudden none of my Fades are working. Even fades to black that I had added before now just cut. I can see the transition image at the end of

  • Deleted PR

    Dear Gurus i am facing one problem, i have delted one purchase requistion after that when i try to make purchase order using same Purchase requistion which I have deleted.system allow me  to make the PO using that PR I want to remove such abnormal be