Join two table using two link field

hi all
i need to left join two table, and to link two table need to match two field
ex: the link field is store_name and id
i use below sql statement
SELECT A1.store_name, A1.id, A1.card, A2.sale, A2.history
FROM Georgraphy A1, Store_Information A2
WHERE A1.store_name = A2.store_name(+)
AND A1.id = A2.id(+)
but it's wrong
please tell me how to left join A1 and A2, thx!

Whats your aim?
Any error message?
SQL> select * from geography;
        ID STORE_NAME
         1 a
         1 b
         2 a
         2 b
SQL> select * from store_information;
        ID STORE_NAME
         1 a
         3 d
SQL> SELECT *
  2  FROM Geography A1, Store_Information A2
  3  WHERE A1.store_name = A2.store_name(+)
  4  AND A1.id = A2.id(+);
        ID STORE_NAME         ID STORE_NAME
         1 a                   1 a
         2 a
         2 b
         1 b                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Find matching records from two tables, useing three key fields, then replace two fields in table1 from table2

    I have two tables - table1 and table2 - that have the exact same schema. There are three fields that can be used to compare the data of the two tables, field1, field2, and field3. When there are matching rows in the two tables (table1.field1/2/3 = table2.field1/2/3)
    I want to replace table1.field4 with table2.field4 and replace table1.field5 with table2.field5.
    I have worked with the query but have come up with goobly goop. I would appreciate any help. Thanks.

    If your field1, field2, and field3 combinations in these tables are unique, you
    can do a join on them.
    Select t1.field4, t2.field4 , t1.field5, t2.field5
    from table1 t1 inner join table2 t2 on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t1.field3=t2.field3
    --You can update your table1 with following code:
    Merge table1 t1
    using table2 t2 on
    on t1.field1 =t2.field1 and t1.field2=t2.field2 AND t3.field3=t2.field3
    When matched then
    Update Set
    t1.field4= t2.field4
    ,t1.field5 = t2.field5 ;

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • Join two tables using union

    Hi Gurus,
    I have three tables. I want to join all tables using union in SQL statement. The query is returning all the records from both tables but i only require unique rows based on a specific column value. Here is my table structure -
    TableA -
    LIC_ID          NUMBER(10)     NOT NULL
    LIC_NUMBER     VARCHAR2(20)
    COMMENCE_DATE     DATE
    EXPIRY_DATE     DATE
    TERM          VARCHAR2(20)LIC_ID is the primary key in this table -
    Sample data from TableA
    LIC_ID          LIC_NUMBER     COMMENCE_DATE          EXPIRY_DATE     TERM
    2          TR4323          12/04/2008          11/03/2010     2 Years
    34          TR5432          23/07/2009          22/07/2010     1 Year
    45          TR5321          24/06/2009          23/06/2010     1 Year
    65          TR6666          23/07/2010          22/07/2011     1 Year
    32          TR2423          30/05/2010          29/05/2011     1 YearTableB -
    MAR_ID          NUMBER(10)     NOT NULL
    LIC_ID          NUMBER(10)     NOT NULL
    ZONE_NAME     VARCHAR2(20)
    DEPARTMENT     VARCHAR2(20)
    ACTIVITIES     VARCHAR2(200)
    COMMENTS     VARCHAR2(200)MAR_ID is the primary key in this table and LIC_ID is the foreign key on TableA
    Sample data from TableB -
    MAR_ID          LIC_ID          ZONE_NAME     DEPARTMENT     ACTIVITIES     COMMENTS
    23          2          ZONE A          IT          NONE               
    43          34          ZONE B          IT          NONE
    33          65          ZONE C          ACCOUNT          NONE     
              TableC
    REC_ID          NUMBER(10)     NOT NULL
    LIC_ID          NUMBER(10)     NOT NULL
    DIST_NAME     VARCHAR2(20)
    REGION          VARCHAR2(20)
    ACTIVITIES     VARCHAR2(200)
    COMMENTS     VARCHAR2(200)REC_ID is the primary key in this table and LIC_ID is the foreign key.
    Sample data -
    REC_ID          LIC_ID          DIST_NAME     REGION          ACTIVITIES     COMMENTS
    2          45          SA          NORTH          NONE
    3          65          TA          NORTH          NONE
    5          32          NT          SOUTH          NONEHere is my sql query -
    select a.lic_id, a.lic_number, a.commence_date, a.expiry_date from
    TableA a, TableB b
    where a.lic_id=b.lic_id
    union
    select a.lic_id, a.lic_number, a.commence_date, a.expiry_date from
    TableA a, TableC c
    where a.lic_id=c.lic_idThe above query returns -
    lic_id          lic_number     commence_date          expiry_date          
    2          TR4323          12/04/2008          11/03/2010     
    34          TR5432          23/07/2009          22/07/2010     
    45          TR5321          24/06/2009          23/06/2010     
    65          TR6666          23/07/2010          22/07/2011     
    32          TR2423          30/05/2010          29/05/2011
    65          TR6666          23/07/2010          22/07/2011     LIC_ID 65 exists in both table TableB and TableC hence it repeats in query but I want to display that only once. How can I do that? I want to return unique record on LIC_NUMBER.
    Hope this make sence.
    Many thanks,
    Tajuddin

    Thanks for all your reply and suggestions. David altering session did not work.
    Sven your idea helped me to figure it out what to do. I found a way around to fix it. Here is my current code -
    select a.lic_id, a.lic_number, a.commence_date, a.expiry_date from
    TableA a, TableB b
    where a.lic_id=b.lic_id
    union
    select a.lic_id, a.lic_number, a.commence_date, a.expiry_date from
    TableA a, TableC c
    where a.lic_id=c.lic_id and c.lic_id not in ( select lic_id from TableB)This will exclude any LIC_ID exists in TableB.
    Thanks again for your help guys.
    Regards,
    M Tajuddin
    Web: http://tajuddin.whitepagesbd.com
    Blog: http://aspblog.whitepagesbd.com

  • How we relate two tables using foreign key(fk)?

    hi to all,
        what are the conditions has to follow to relate two tables.I.e.,
    the two tables have same primary keys(pk). if we relate these two tables in one table the pk and fk will be the same then how that table in active.

    Hi
    To relate two tables..we have foreign key relationship.
    In one table v have primary key and in the second table, the same key is foreign key for that table..
    To relate two tables, we can use JOINS
    If there is already a suitable foreign key between two tables used in the view, these tables can be linked with a join condition from this foreign key.
    Create a view on tables TAB1 and TAB2. TAB1 is the primary table of the view. TAB2 is the secondary table of the view. TAB1 is the check table for TAB2. The foreign key fields are assigned to the check table fields as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    The join condition of the view generated from the foreign key is then:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = TAB1-FIELD_B.
    Join conditions can also be copied from generic and constant foreign keys. If a constant is assigned to a field in the foreign key, it is also assigned to the field in the join condition. There is no join condition for a generic relationship in the foreign key.
    The foreign key between tables TAB1 (check table) and TAB2 (foreign key table) is defined as follows:
    TAB1-FIELD_A assigned to TAB2-FIELD_1
    TAB1-FIELD_B generic
    TAB1-FIELD_C assigned to constant ‘C’
    The join condition for the view generated from the foreign key is in this case:
    CREATE VIEW ... AS SELECT ... WHERE TAB2-FIELD_1 = TAB1-FIELD_A AND TAB2-FIELD_2 = ‘C’.
    Hope it helps
    Reward if useful.

  • Joining two tables in two different schema

    Hi All,
    I have a requirement to join two tables in two different schema. How to join these two tables in view object.
    Many thanks in advance.
    Regards
    Kaushik Gopalakrishnan

    1) If these tables are in one and same database instance, then you can join them by specifying the fully-qualified table names (inlcuding the schema name), for example:
    SELECT ...
    FROM schema_A.table1 T1, schema_B.table2 T2
    WHERE T2.parent_code = T1.code
         AND ...2) If the tables are in different database instances, then you can create a database link in one of the databases and access the table from the other database via the DB link, for example:
    SELECT ...
    FROM schema_A.table1 T1, schema_B.table2@mydblink T2
    WHERE T2.parent_code = T1.code
         AND ...3) If the tables are in different database instances and there is no option for DB links, then you cannot join the tables in an ADF ViewObject.
    Dimitar

  • Operates on two table using procedure

    i want to handle two table using procedure in oracle 10g. i have created a procedure like this
    CREATE OR REPLACE PROCEDURE sold_car1(
    sid soldcar.sold_id%TYPE,
    cid soldcar.id%TYPE,
    cuid soldcar.customer_id%TYPE,
    eid soldcar.emp_id%TYPE,
    d soldcar.dat%TYPE
    ) IS
    BEGIN
    INSERT INTO soldcar VALUES(sid,cid,cuid,eid,to_date(d,'yyyy/mm/dd'));
    DELETE FROM pcar where id=cid;*
    COMMIT;
    END sold_car1;
    SHOW ERRORS
    i have found some errors. how can i do this.

    hi
    the errors are something like this ''the procedure is created with some errors''.
    actually i want to pass 4 parameters in the procedure that will insert in one table and among the 4 parameters by using one parameter i want to delete one row of another table.
    INSERT INTO soldcar VALUES(sid,cid,cuid,eid,to_date(d,'yyyy/mm/dd')); //soldcar is first table
    DELETE * FROM pcar where id=cid; //pcar is second table

  • How to select data from a table using a date field in the where condition?

    How to select data from a table using a date field in the where condition?
    For eg:
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
                                                      and bdatu = '31129999'.
    thanks.

    Hi Ramesh,
    Specify the date format as YYYYMMDD in where condition.
    Dates are internally stored in SAP as YYYYMMDD only.
    Change your date format in WHERE condition as follows.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and bdatu = <b>'99991231'.</b>
    I doubt check your data base table EQUK on this date for the existince of data.
    Otherwise, just change the conidition on BDATU like below to see all entries prior to this date.
    data itab like equk occurs 0 with header line.
    select * from equk into table itab where werks = 'C001'
    and <b> bdatu <= '99991231'.</b>
    Thanks,
    Vinay
    Thanks,
    Vinay

  • How can i make calculation in two file using two parameter

    how can i make calculation in two file using two parameter
    Solved!
    Go to Solution.

    i am having two differnt file, both file having no and time , i want to make programme that when, number and tiome is same in both file give that index onle  in , i am going to attached the file
    Attachments:
    iisc11-jan2010extract.txt ‏1253 KB
    sp3.xlsx ‏12 KB

  • I am creating a request for proposal form and I need to add a commission structure field.  I created a table using the ranking field and now I need to delete the "dots/buttons" and turn them into text fields, is this possible?

      I created a table using the ranking field and now I need to delete the "dots/buttons" and turn them into text fields, is this possible?

    It sounds like what you are trying to do is edit the choices in a likert field to something other than the default radio button. This is not something that you can do in Formscentral at this time.
    Andrew

  • Joining multiple tables using ANSI join

    Hi,
    I need to join 4 tables using ANSI join. Lets say they are A,B,C adn D. A and B has a common column called x. C and D had a common column called y. I wrote a query like this
    select * from A left outer join B on (A.x=B.x),
    C left outer join D on (C.y =D.y)
    its not working!!!
    I need to use ANSI join.
    can any body help me please???

    Hi,
    But is there is any common column between A,C or B,C or D,A?
    Let me know.

  • How to calculate the ratio between the maximum and minimum peaks of the two waves using two looping to find the value of SPO2?

    hello everyone,
    i'm rai from indonesia
    I have a final project about pulse oximetriy, I have some problems,
    how to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops to calculate SpO2 ?
    My program image can be seen below predicament ?
    Attachments:
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB

    Hi rai,
    I would appreciate it as kind of respect for forum participants if you would clean up your VI before uploading it (or images of its block diagram)…
    That being said:
    - Your inner while loops each run exactly twice. Replace them with FOR loops!
    - Lots of unneeded operations, mainly induced by ExpressVI usage. Is there a reason to convert to DDT and immediately convert back to 1D array?
    - You already calculate some Min/Max values. Ratio is just a division of two values…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops?

    hello everyone,
    i'm rai from indonesia
    I have a final project about pulse oximetriy, I have some problems,
    how to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops to calculate SpO2 ?
    My program image can be seen below predicament ?
    Attachments:
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB

    Hi Rai,
    You should post this into the LabVIEW forum rather than Real-Time since this isn't a Real-Time application. Your post will see more replies in the LabVIEW forum. 
    As far as your question is concerned, you can write the max and min from the respective loops to a local variable to send the data out of the loops to a third loop or just do the calculation in one of the loops. This would be ideal if you're trying to do this while the loop is running. 
    -Jayk
    Applications Engineering
    National Instruments

  • Joining two tables having no common fields using one select query

    Hi Experts,
    How to join two tables which are NOT having any field in common using only one select query?
    Your help will be appreciated.
    Thank you.

    Identify a third table (or more tables) with common fields with your two tables, or change your question either removing JOIN or removing NO COMMON FIELDS, else you wont get many responses and will be left alone in outer space, as suggested by Thomas.
    If you acturally require what you written, better execute two select and merge the two internal tables merging every record from first table with every record of second table, til no more memory is available.
    Regards,
    Raymond

  • Join on two tables using "LIKE"

    Hi all,
    I need make join on two tables (QMEL and STXL) using keys for connection:
    - field for join of first table is (QMEL-QMNUM - Notif. number - Char 12)
    - field for join of second table is  (STXL-TDNAME - Char 70)
    If it is connection based on EQ, I think, it's no problem but I need to connect it on base of 'LIKE'.
    Example:
    QMEL-QMNUM = '100100698075'
    I would like get all rows from STXL which contain or even better start with notif. number.
    Examples I would like connect with QMEL-QMNUM:
    STXL-TDNAME = '100100698075'
    STXL-TDNAME = '1001006980750001'
    STXL-TDNAME = '10010069807500010001'
    STXL-TDNAME = '10010069807500010002'
    etc..
    Am I able to manage that with select which join these two tables this way?
    Thanks for any solution
    Vaclav Hosek.

    Hi,
    Write 2 separate selects for this.
    select * from QMEL
    where......
    if sy-subrc = 0.
    loop at i_qmel into wa.
    r_tdname-option = 'CP'.
    r_tdname-sign = 'I'
    concatenate wa-qnum '*' into r_tdname-low.
    append r_tdname.
    endloop.
    select *
    from STL
    where tdname in r_tdname.
    endif.

Maybe you are looking for

  • Pages 3.0 crashes opening a long document

    Hi there, I am running Pages 3.0 (with all current updates) on an iMac with Os 10.5.7 and 2 Gb of RAM. I have a very long document (almost 200 pages) with pictures and tables that worked fine until yesterday. I usually make a backup copy of the file

  • Erase All Content and Settings on my iPod Touch

    I'm trying to delete an old email address from my iPod Touch. It doesn't show up in Contacts and it has been deleted from my AOL, Yahoo, and gmail Contacts lists both in my iPod and on the laptop I use to synch the iPod. When I open my iPod and click

  • Help with a database link?

    Hiya In our environment we have two servers for live and two for test. LIVE01 has db links to all other servers and they all work fine. I cannot get the db links up on test and I'm not sure why.. Both systems have global_names set FALSE so i can name

  • How to improve performance for this code

    Hi, LOOP AT lt_element INTO ls_element. READ TABLE lt_element_ident INTO ls_element_ident WITH KEY element_id = ls_element-element_id BINARY SEARCH. IF sy-subrc EQ 0. MOVE ls_element_ident-value TO lv_guid. SELECT * FROM zcm_valuation_at APPENDING CO

  • Impdp Query parameter

    Hi I have the following query parameter in my parfile QUERY=SYSADMIN:INVOICE"Where Invoice_date>TO_DATE('01JAN09','DDMONYY')" When I start the Import job it is doing a full table scan on the source table - Ideally it must use the index on invoice dat