Inner Join of 3 tables is correct or not?

Hi Guys ,
             I have a requirement where i have to join 3 tables i  dont know whether the inner Join which i wrote for 3 tables is correct or not.I am not getting any Syntax error but whether the logci below which i wrote gets all the records or not.
The Requirement is
"c.     Select the BOL Number entered in the screen and query the table LIKP with the BOL number in the field LIKP-BOLNR.  Gather the list of ALL delivery documents (LIKP-VBELN) that is outputted.
d.     Query the list of the delivery documents obtained into the table VBFA in the field VBFA- VBELV.  From the output that is displayed, select the Follow-On Document Field (VBFA-VBELN) for that item whose Subsequent Document Category (VBFA- VBTYP_N) is R and the Movement Type (VBFA- BWART) is 641.  Get the Follow-On document number for each of the above Delivery Document number.
e.     Query the table EKBE with the Follow On document obtained above in the field Material Document (EKBE- BELNR).  Perform this activity for each of the follow on document obtained above.  Get the resultant Purchase Order (EKBE-EBELN) and Item Number (EKBE-EBELP) from the query.  After querying will all the Follow-On Documents, get the unique list of PO number and Item Number.
The logic which i wrote is
                Begin of t_PoolSTO_out,
              BOLNR type LIKP-BOLNR,
              EBELN type EKBE-EBELN,
              EBELP type EKBE-EBELP,
              VBELN type LIKP-VBELN,
              VBELNV type VBFA-VBELN,
         End of t_PoolSTO_out.
      Data: i_PoolSTO type Standard table of t_PoolSTO_out.
  Select
        a~BOLNR
        c~EBELN
        c~EBELP
        a~VBELN
        b~VBELN
        from LIKP as a
        Inner Join VBFA as b on aVBELN = bVBELV
        Inner Join EKBE as c on bVBELN = cBELNR
        into Table i_PoolSTO
        Where a~BOLNR in S_LBLNE and
              b~VBTYP_N = 'R' and
              b~BWART = '641'.
          My doubt is whether the logic works or not i Mean does i getall the rrecords based on the requirement.?
                  If not please tell any alternative logic?
Thanks,
Gopi Anne.

Hi Gopi,
Your code is Good.
But try to avoid Inner join with more number of Tables ...because this is a performance issue..
try to use..
select (primary key fields mainly,other fields) from LIKP into itab where bolnr in p_bolnr(paramater).
next try to use for all entries option..
select (primary key fields mainly,other fields) from VBFA for all entries in itab where (give the condition)....
simillarly do for the other select ....ok this will try to reduce the performance issue....
<b><REMOVED BY MODERATOR></b>
Message was edited by:
        Alvaro Tejada Galindo

Similar Messages

  • Inner join on Buffred table and not buffered table.

    Hi guys,
       Can you suggest me how can i write select query using inner join on buffered table and not buffered table. i written like this. is it right?
    SELECT a~vbeln                         
             a~vkorg   
             a~kunnr                         
             a~kunag                         
             a~wadat_ist 
             a~xblnr                         
             b~bukrs
       FROM likp AS a INNER JOIN tvko AS b
        ON avkorg = bvkorg BYPASSING BUFFER
      INTO TABLE itab_likp
      WHERE vbeln = s_vbeln.              
    Thanks.
    RAJ

    Hi Raj ,
    Please find below my Commentes :
    1. When you use "Bypassing buffer" clause in Select statement , the data what is there in the buffer of application sever is always ignored and Read is performed from the Physical database always. This Clause is advisable where you require realtime data (Not recommended generally in reporting)
    2. It is advisable that you should not use small table in the innerjoin with big table. In the query you have written there are 2 tables:- LIKP and TVKO outof which TVKO is a master table containing very few records than LIKP (Contains huge data for Delivery header).
    So my recommendation will be : -
    1. Eliminate the "Bypassing Buffer" clause from your Query
    2. Break the select query into 2 select queries breaking the join and with some ABAP logic populate the Internal table "itab_likp".
    This will be optimum way inwhich you can write the select query for your senarion. Also Ensure that indexes are being used for better selectivity.
    Hope this will help to you.
    Regards,
    Nikhil

  • Can I di Inner Join on 2 tables by using only 1 key field?

    Hello,
    I hv 2 Std. SAP tables, KNVV, KNKK.
    - KNVV - does hv 2 key fields (KUNNR and some other, say X)
    - KNKK - does hv 2 key fields (KUNNR and some other,say Y)
    I want to build a inner join on these 2 tables.
    So, Can I do a INNER JOIN on these 2 tables by using ONLY one key field (its KUNNR)? bcoz, there is ONLY common field!!
    thank you

    Hi,
    The correctness depends on your bussiness requirement. If the common key field is not a primary key, you may end up fetching duplicate entries which you may have to delete after the select query. You dont have to take of any extra precautions in a inner join select query compared to a ordinary select query. Just make sure you use most of the primary key fields of both the tables  in the where clause of the select query for better performance
    Vikranth

  • Inner join on four tables

    hi all,
    i am facing the problem with the inner join in the select query for 4 tables.
    can i use the inner join for tables in SAP 6.0 version,
    it is going to dump.
    here is my code
    SELECT DISTINCT apernr abegda aendda awagetype aamount acurrency
            altrctry brufnm banred bvorna bnachn cgroupcode d~vdsk1
    FROM pa9011 AS a INNER JOIN pa0002 AS b ON bpernr = apernr
                      INNER JOIN pa9013 AS c ON cpernr = bpernr
                      inner join pa0001 as d on dpernr = cpernr
                      INTO CORRESPONDING FIELDS OF TABLE it_bonus
    WHERE a~pernr IN s_pernr AND
           a~begda IN s_date AND
           a~subty EQ s_subty AND
           a~wagetype EQ wa_perbonus AND
           a~ltrctry = gc_ind AND
           a~amount > 0 AND
           b~endda = '99991231' AND
           c~groupcode IN s_loc AND
           c~endda = '99991231' and
           d~endda = '99991231'
        ORDER BY a~pernr.

    hi this is the dump ,
    In a SELECT access, the read file could not be placed in the target
    field provided.
    Either the conversion is not supported for the type of the target field,
    the target field is too small to include the value, or the data does not
    have the format required for the target field.

  • Confusion in Select query having a inner join on single table

    Hi,
    I was going through coding and came a accross a select query which has a inner join on a single table. I am getting confused while analysing this . Please someone can help me analysing this query.
    select
            m~MATERIAL
            s~NUMERATOR s~DENOMINTR
            m~GROSS_WT  m~UNIT_OF_WT
          into table itab
          from ( table1as s
           inner join table1 as m
           on  m~MATERIAL = s~MATERIAL
          and m~MAT_UNIT = 'CS'
          and m~SOURSYSTEM = s~SOURSYSTEM )
          where s~MAT_UNIT = 'EA'
             and s~SOURSYSTEM = 'LD'
             and s~OBJVERS = 'A'
             and s~MATERIAL IN ( Select mat_sales
                from Table2  group by mat_sales ).
    Thank you
    Kusuma

    I don't see any use of the INNER JOIN here.
    But what's the meaning of the last selection clause?
    s~MATERIAL IN ( Select mat_sales
                from Table2  group by mat_sales ).
    Is that native SQL or something?
    Pushpraj

  • INNER join with dynamic table name ?

    Hi,
    I have a problem with this statement.
    DATA: g_dso_bic_dofr TYPE tabname.
    SELECT t1~/bic/ziparomr
           t2~/bic/zifremom
    INTO (wa_rater_paromr-/bic/ziparomr,
           wa_rater_paromr-/bic/zifremom)
    *   FROM /bic/azd0bfr5100 AS t1     "equivalent to the dynamic statement below
    " this is the  problem
        FROM (g_dso_bic_dofr )AS t1
        INNER JOIN /bic/pzifremom AS t2
          ON t1~/bic/ziparomr = t2~/bic/ziparomr
    " --- to here
        WHERE t1~/bic/zikom     =  v_kommune
    The compile check doesnt work when i use the variable table name.
    I get
    "Wrong expression "INNER" in FROM clause. WHERE condition."
    Can anyone help me.
    Br Rasmus.

    " this is the  problem
    *    FROM (g_dso_bic_dofr )AS t1   "<<--- check spaces in here
        FROM (g_dso_bic_dofr) AS t1    "<<--- and here
        INNER JOIN /bic/pzifremom AS t2
          ON t1~/bic/ziparomr = t2~/bic/ziparomr
    " --- to here
    I think there's the problem, the space behind the parenthesis.
    Regards

  • Inner joins on the tables VAKPA , VBAP and KNA1

    HI ,
    I have one performance issue.please see the below select query..In order to improve the performance i need to change this select query with out changing the functionality.Can any one of you please suggest me .
       SELECT vakpakunde vakpaparvw kna1kunnr kna1name1 kna1~ktokd
               vbapvbeln vbapposnr vbaparktx vbapzzclass
               vbapmvgr2 vbapmvgr3 vbapmvgr5 vbapzzcanvas_year
               vbapmatnr vbapmatkl
         FROM  vakpa
         INNER JOIN  vbap ON
               vakpavbeln = vbapvbeln
         INNER JOIN kna1 ON
               vakpakunnr = kna1kunnr
         INTO CORRESPONDING FIELDS OF TABLE gt_vbap
         WHERE vakpa~kunde IN so_kunnr
         AND   vakpa~parvw = 'AG'
         AND   vakpa~vkorg IN so_vkorg
         AND ( vbap~zzad_line_status = 'PR' OR
               vbap~zzad_line_status = 'RE' )
         AND   vbap~mvgr5         IN r_ctf
         AND   vbap~matkl         IN so_matkl
         AND   vbap~matnr         IN so_matnr
         AND   vbap~zzcanvas_year IN so_year.
      ENDIF.

    Use FOR ALL ENTRIES statement instead of joints.
    or
    and Remove INTO CORRESPONDING FIELDS by selecting the fields in the orderstored in table
    Edited by: kalandar on Dec 4, 2009 7:43 AM

  • Inner join for three table

    dear friends
    kna1- kunnr ,name1
    vbak - vbeln , erdat
    vbap - meins , kwmeng
    on above i have given three tables and their fields in front of this
    can any one tel me how to give inner join in select statement for the above tables

    Hi Create an appropriate internal table ITAB
    Select VBAK~VBELN
               VBAK~ERDAT
               VBAP~POSNR
               VBAP~MEINS
               VBAP~kwmeng
               KNA1~KUNNR
               KNA1~NAME1
    From VBAK
    Into Table ITAB
    Inner Join VBAP On VBAKVBELN = VBAPVBELN
    Inner Join KNA1 On VBAK~KUNNR = KNA1-KUNNR
    Where VBAK~VBELN In S_VBELN.
    Santhosh

  • Problem when doing inner join for three tables....

    DATA: V3 TYPE VBAP-MAKTL.
    SELECT single vbap~matkl into V3
           from VBAP
           inner join VBFA
           inner join LIPS
              on LIPSPOSNR = VBFAPOSNN
              and vbapvbeln = vbfavbelv
               and vbapposnr = vbfaposnv
                 where LIPSVBELN = VBFAVBELN = '0080000834'
                 and vbfa~vbtyp_n = 'J'
                 and LIPS~J_3ASIZE = '0884'.
    Error: Wrong expression "INNER" in from clause...

    Hello Tushar,
      Why you are using the 3 table inner join. If the volume of data is big then this statement will give to time out. Use "for all entries" statement to select the data from the table.
    Like
    select field1 field2 from LIPS into i_lips
        where LIPS~J_3ASIZE = '0884'.
    select f3 f4 from vbfa into i_vbfa for all entries in i_lips where field1 = i_lips-field1 and so on
    and 
    use same to select data from VBAP.
    Hope this will help

  • Inner join on internal table

    HI all,
    How to access data from two internal table using join condition ?
    suppose i have tow internal table itab and jtab and i want to access data by using inner join on this tow table.
    please tell .
    thanx..

    hi,
    You can use PROVIDE ENDPROVIDE statements in ABAP to achive this.
    Check the below documenttaion.
    PROVIDE
    Syntax
    PROVIDE FIELDS {*|{comp1 comp2 ...}}
                   FROM itab1 INTO wa1 VALID flag1
                   BOUNDS intliml1 AND intlimu1
                   [WHERE log_exp1]
            FIELDS {*|{comp1 comp2 ...}}
                   FROM itab2 INTO wa2 VALID flag2
                   BOUNDS intliml2 AND intlimu2
                   [WHERE log_exp2]
            BETWEEN extliml AND extlimu
            [INCLUDING GAPS].
    ENDPROVIDE.
    Effect
    The statements PROVIDE and ENDPROVIDE define a loop through a statement block. In this loop, any number of internal tables itab1 itab2 ... are processed together. A single table can appear several times. For every table itab you must specify a FIELDS clause. After FIELDS you must specify the character * for all components or a list comp1 comp2 ... for specific components of the relevant table. The names of the components comp1 comp2 ... can only be specified directly.
    To be able to process internal tables using PROVIDE, all tables itab1 itab2 ... must be fully typed index tables and contain two special columns that have the same data type (d, i, n, or t) for all relevant tables. For every table you must specify the names intliml1 intliml2 ... and intlimu1 intlimu2 ... of these columns using the addition BOUNDS.
    The columns intliml1 intliml2 ... and intlimu1 intlimu2 ... in every row of the relevant internal tables must contain values that can be interpreted as limits of closed intervals. Within a table, the intervals specified in these columns must not overlap and must be sorted in ascending order. The intervals therefore make up a unique key for every row.
    For every table you must specify a work area wa1 wa2 ... compatible with the row type and a variable flag1 flag2 ..., for which a character-type data type with length 1 is expected. In the PROVIDE loop, the components specified after FIELDS are filled with values in the relevant work areas wa1 wa2 ... for every specified internal table. The variables flag1 flag2 ... are also filled. A work area wa1 wa2 ... or a variable flag1 flag2 ... cannot be specified more than once.
    With the BETWEEN addition you must specify an interval extliml, extlimu. It must be possible to convert the data objects extliml and extlimu into the data types of the respective columns intliml1 intliml2 ... and intlimu1 intlimu2 ... of the individual tables.
    The interval limits intliml1 intliml2 ... and intlimu1 intlim2 for every row of all relevant internal tables itab1 itab2 ... that are within the closed interval made up by extliml and extlimu divide the latter into new intervals and every interval limit closes one interval in the original direction. If, within a relevant table, a lower interval limit follows an upper interval limit with no space or gap between them and the components of the corresponding rows specified after FIELDS have the same content, the two intervals are combined and the corresponding interval limits intliml1 intliml2 ... and intlimu1 intlimu2 ... are ignored for the new intervals.
    For every interval that is created in such a way and overlaps with at least one of the intervals of a table involved, the PROVIDE loop is passed once. The components of every work area wa1 wa2 ... specified after FIELDS and the variables flag1 flag2 ... are filled with values as follows:
    The components intliml1 intliml2 ... and intlimu1 intlimu2 ... of every work area wa1 wa2 ... are filled with the interval limits of the current interval.
    If the current interval overlaps with one of the intervals of an involved table, the remaining components of the corresponding work area are assigned the contents of the relevant components of this table row and the variable flag1 flag2 ... is set to the value "X". Otherwise, the work area components and the variables flag1 flag2 ... are set to their Initial value.
    Except for intliml1 intliml2 ... and intlimu1 intlimu2 ..., the components not specified after FIELDS are always set to their initial value. The components intliml1 intliml2 ... and intlimu1 intlimu2 ... are always assigned.
    The ABAP runtime environment checks for every table involved, whether the condition of sorted and non-overlapping intervals is met within the interval made up by extliml and extlimu and, if necessary, triggers an exception that can be handled.
    If the INCLUDING GAPS addition is specified, the system passes the PROVIDE loop for every interval, that is also when the current interval does not overlap with at least one of the intervals of an involved table. In the latter case, the variable flag is of initial value for every relevant table.
    You can use the WHERE addition to specify a condition for every table itab1 itab2 ... involved. After WHERE, you can specify any logical expression log_exp1 log_exp2 ... ; the first operand of every comparison must be a component of the internal table. As such, all logical expressions except for IS ASSIGNED, IS REQUESTED, and IS SUPPLIED are possible. You can only specify components that are in the list after FIELDS. Here it is not possible to specify a component using character-type data objects in brackets. The table entries for which the condition is not met are ignored by the PROVIDE loop. You can leave the PROVIDE loop following the instructions in the section Leaving loops.
    System fields
    The system fields sy-subrc and sy-tabix are set to the value 0 before every loop pass and at ENDPROVIDE. Only if the loop is not passed once, is sy-subrc set to 4 at ENDPROVIDE.
    Notes
    The relevant internal tables should not be modified in the PROVIDE loop.
    The WHERE condition can be used to remove overlaps between the tables involved or to ensure the sorting of the intervals.
    In two tables itab1 and itab2, the respective columns col1 and col2 are interval limits of type i. The filling of the internal tables results in the following intervals (rows two and three):
    |01|02|03|04|05|06|07|08|09|10|11|12|13|14|
    |   Itab1 Int1    |     |Itab1 Int2 |     |
    |        |      Itab2 Int1       |        |
    |  |          ... BETWEEN ...             |
    |  | i1  |   i2   | i3  |   i4   |i5|     |
    The interval specified in the BETWEEN addition to the PROVIDE statement is shown in the fourth row. It serves as a basis for the five intervals in the fifth row represented by i1 to i5. These can be processed in the PROVIDE loop.
    Because each of the five intervals overlaps with one of the intervals from rows two and three, the PROVIDE loop is passed five times.
    Only the component col3 of wa1 is filled in the first pass, only the component col3 of wa2 in the third pass, and the components col3 of both work areas in the second and fourth passes. The fields valid1 and valid2 are set accordingly.
    DATA: BEGIN OF wa1,
            col1 TYPE i,
            col2 TYPE i,
            col3 TYPE string,
          END OF wa1.
    DATA: BEGIN OF wa2,
            col1 TYPE i,
            col2 TYPE i,
            col3 TYPE string,
          END OF wa2.
    DATA: itab1 LIKE STANDARD TABLE OF wa1,
          itab2 LIKE STANDARD TABLE OF wa2.
    DATA: flag1(1) TYPE c,
          flag2(1) TYPE c.
    wa1-col1 = 1.
    wa1-col2 = 6.
    wa1-col3 = 'Itab1 Int1'.
    APPEND wa1 TO itab1.
    wa1-col1 = 9.
    wa1-col2 = 12.
    wa1-col3 = 'Itab1 Int2'.
    APPEND wa1 TO itab1.
    wa2-col1 = 4.
    wa2-col2 = 11.
    wa2-col3 = 'Itab2 Int1'.
    PROVIDE FIELDS col3 FROM itab1 INTO wa1
                                   VALID flag1
                                   BOUNDS col1 AND col2
            FIELDS col3 FROM itab2 INTO wa2
                                   VALID flag2
                                   BOUNDS col1 AND col2
            BETWEEN 2 AND 14.
      WRITE: / wa1-col1, wa1-col2, wa1-col3, flag1.
      WRITE: / wa2-col1, wa2-col2, wa2-col3, flag2.
      SKIP.
    ENDPROVIDE.
    The list output is as follows:
       2           3  Itab1 Int1 X
       2           3
       4           6  Itab1 Int1 X
       4           6  Itab2 Int1 X
       7           8
       7           8  Itab2 Int1 X
       9          11  Itab1 Int2 X
       9          11  Itab2 Int1 X
      12          12  Itab1 Int2 X
      12          12
    Exceptions
    Catchable Exceptions
    CX_SY_PROVIDE_INTERVAL_OVERLAP
    Cause: In one of the involved tables there are overlapping intervals within extlim1 and extlim2.
    Runtime Error: UNCAUGHT_EXCEPTION
    CX_SY_PROVIDE_TABLE_NOT_SORTED
    Cause: One of the involved tables is not sorted in ascending order by the intervals within extlim1 and extlim2.
    Runtime Error: UNCAUGHT_EXCEPTION
    Edited by: Velangini Showry Maria Kumar Bandanadham on Apr 28, 2008 1:36 PM

  • Inner join for two tables

    Hello All
    i have these to tables
    country: name,population
    borders: country1,country2
    every country have some neghbors, in borders table,
    now i should calculate sum of pupulation of all neighbors of every country
    thank u so much for ur help
    I use oracle 11g
    best

    This is the SQL to create the table
    now i hope i will get an answer
    --  File created - Tuesday-April-30-2013  
    --  DDL for Table BORDERS
      CREATE TABLE "intern"."BORDERS" ("COUNTRY1" CHAR(2), "COUNTRY2" CHAR(2), "LENGTH" NUMBER)
       COMMENT ON COLUMN "intern"."BORDERS"."COUNTRY1" IS 'a country code'
       COMMENT ON COLUMN "intern"."BORDERS"."COUNTRY2" IS 'a country code'
       COMMENT ON COLUMN "intern"."BORDERS"."LENGTH" IS 'length of the border between country1 and country2'
       COMMENT ON TABLE "intern"."BORDERS"  IS 'informations about neighboring countries'
    REM INSERTING into intern.BORDERS
    SET DEFINE OFF;
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ad','es',63);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('md','ua',939);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mk','yu',221);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','mr',2237);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','ne',821);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ml','sn',419);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mm','th',1800);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mn','ru',3543);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mr','sn',813);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','mz',1569);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','tz',475);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mw','zm',837);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mx','us',3141);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('my','th',506);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','sz',105);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','tz',756);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','za',491);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','zm',419);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('mz','zw',1231);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('na','za',967);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('na','zm',233);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ne','ng',1497);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ne','td',1175);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ng','td',87);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('no','ru',196);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('no','se',1619);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('om','sa',676);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('om','ye',288);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','ru',206);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','sk',444);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('pl','ua',526);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('qa','sa',60);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ro','ua',531);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ro','yu',476);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('ru','ua',1576);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('rw','tz',217);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('rw','ug',169);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sa','ye',1458);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sd','td',1360);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sd','ug',435);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sk','ua',97);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sy','tr',822);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('sz','za',430);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tj','uz',1161);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tm','uz',1621);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tz','ug',396);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('tz','zm',338);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('za','zw',225);
    Insert into intern.BORDERS (COUNTRY1,COUNTRY2,LENGTH) values ('zm','zw',797);
    --  DDL for Index BORDERS_KEY
      CREATE UNIQUE INDEX "intern"."BORDERS_KEY" ON "intern"."BORDERS" ("COUNTRY1", "COUNTRY2")
    --  Constraints for Table BORDERS
      ALTER TABLE "intern"."BORDERS" ADD CONSTRAINT "BORDERS_KEY" PRIMARY KEY ("COUNTRY1", "COUNTRY2") ENABLE
      ALTER TABLE "intern"."BORDERS" ADD CONSTRAINT "BORDERS_LENGTH_CHECK" CHECK (
                 Length > 0
            ) ENABLE
    --  File created - Tuesday-April-30-2013  
    --  DDL for Table COUNTRY
      CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER)
       COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
       COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
       COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
       COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
       COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
       COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
       COMMENT ON TABLE "intern"."COUNTRY"  IS 'the countries of the world with some data'
    REM INSERTING into intern.COUNTRY
    SET DEFINE OFF;
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Afghanistan','af','Kabul','Kabul',28513677,647500);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Antigua and Barbuda','ag','Saint Johns','Saint John',68320,442.6);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Netherlands','nl','Amsterdam','Noord-Holland',16318199,41526);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Norway','no','Oslo','Akershus',4574560,324220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Nepal','np','Kathmandu','Kathmandu',27070666,140800);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Nauru','nr',null,null,12809,21);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Niue','nu',null,null,2156,260);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('New Zealand','nz','Wellington','Wellington',3993817,268680);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Oman','om','Muscat','Muscat',2903165,212460);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Panama','pa','Panama','Panama',3000463,78200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Peru','pe','Lima','Lima y Callao',27544305,1285220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('French Polynesia','pf','Papeete','Iles du Vent',266339,4167);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Papua New Guinea','pg','Port Moresby','National Capital District',5420280,462840);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Philippines','ph','Manila','National Capital Region',86241697,300000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Pakistan','pk','Islamabad','Federal Capital Area',159196336,803940);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Poland','pl','Warsaw','Mazowieckie',38626349,312685);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Pierre and Miquelon','pm','Saint-Pierre','Saint-Pierre',6995,242);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Pitcairn Islands','pn',null,null,46,47);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Puerto Rico','pr','San Juan','San Juan',3897960,9104);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Palestine','ps','Ramallah','Gaza Strip',3762005,6220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Portugal','pt','Lisbon','Lisboa e Vale do Tejo',10524145,92391);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Palau','pw','Koror','Koror',20016,458);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Paraguay','py','Asuncion','Asuncion',6191368,406750);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Qatar','qa','Doha','Doha',840290,11437);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Reunion','re','Saint-Denis','Saint-Denis',766153,2517);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Romania','ro','Bucharest','Bucharest',22355551,237500);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Russia','ru','Moscow','Moscow',143782338,17075200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Rwanda','rw','Kigali','Ville de Kigali',7954013,26338);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saudi Arabia','sa','Riyadh','Riyadh',25795938,1960582);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Solomon Islands','sb','Honiara','Guadalcanal',523617,28450);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Seychelles','sc',null,null,80832,455);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sudan','sd','Khartoum','Khartoum',39148162,2505810);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sweden','se','Stockholm','Stockholm',8986400,449964);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Singapore','sg',null,null,4353893,692.7);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Helena','sh','Jamestown','Saint Helena',7415,410);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Slovenia','si','Ljubljana','Osrednjeslovenska',2011473,20273);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Svalbard','sj','Longyearbyen','Svalbard',2756,62049);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Slovakia','sk','Bratislava','Bratislavsky',5423567,48845);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sierra Leone','sl','Freetown','Western',5883889,71740);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('San Marino','sm','San Marino','San Marino',28503,61.2);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Senegal','sn','Dakar','Dakar',10852147,196190);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Somalia','so','Mogadishu','Banadir',8304601,637657);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Suriname','sr','Paramaribo','Paramaribo',436935,163270);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Sao Tome and Principe','st','Sao Tome','Agua Grande',181565,1001);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('El Salvador','sv','San Salvador','San Salvador',6587541,21040);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Syria','sy','Damascus','Damascus',18016874,185180);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Swaziland','sz','Mbabane','Hhohho',1169241,17363);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turks and Caicos Islands','tc',null,null,19956,430);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Chad','td','NDjamena','Chari-Baguirmi',9538544,1284000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Togo','tg','Lome','Maritime',5556812,56785);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Thailand','th','Bangkok','Bangkok Metropolitan Area',64865523,514000);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tajikistan','tj','Dushanbe','Dushanbe',7011556,143100);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tokelau','tk',null,null,1405,10);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turkmenistan','tm','Asgabat','Asgabat',4863169,488100);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tunisia','tn','Tunis','Tunis',9974722,163610);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tonga','to','Nukualofa','Tongatapu',110237,748);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('East Timor','tp','Dili','Dili',1019252,15007);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Turkey','tr','Ankara','Ankara',68893918,780580);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Trinidad and Tobago','tt','Port of Spain','Port of Spain',1096585,5128);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tuvalu','tv','Vaiaku','Funafuti',11468,26);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Taiwan','tw','Taipei','Taipei Hsien',22749838,35980);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Tanzania','tz','Dar es Salaam','Dar es Salaam',36588225,945087);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Ukraine','ua','Kiev','Kiev',47732079,603700);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uganda','ug','Kampala','Central',26404543,236040);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United Kingdom','uk','London','England',60270708,244820);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('United States','us','Washington','District of Columbia',293027571,9631418);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uruguay','uy','Montevideo','Montevideo',3399237,176220);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Uzbekistan','uz','Tashkent','Tashkent',26410416,447400);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Holy See','va',null,null,921,0.44);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Saint Vincent and the Grenadines','vc','Kingstown','Saint George',117193,389);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Venezuela','ve','Caracas','Distrito Capital',25017387,912050);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('British Virgin Islands','vg','Road Town','Tortola',22187,153);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Virgin Islands','vi','Charlotte Amalie','Saint Thomas',108775,352);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Vietnam','vn','Ha Noi','Dong Bang Song Hong',82689518,329560);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Vanuatu','vu','Vila','Shefa',202609,12200);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Wallis and Futuna','wf','Matautu','Hahake',15880,274);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Samoa','ws','Apia','Apia Urban Area',177714,2944);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Yemen','ye','Sana','Amanah al-Asmah',20024867,527970);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Mayotte','yt','Mamoudzou','Mayotte',186026,374);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Serbia and Montenegro','yu','Belgrade','Central Serbia',10825900,102350);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('South Africa','za','Pretoria','Gauteng',42718530,1219912);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Zambia','zm','Lusaka','Lusaka',10462436,752614);
    Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA) values ('Zimbabwe','zw','Harare','Harare',12671860,390580);
    --  DDL for Index COUNTRY_KEY
      CREATE UNIQUE INDEX "intern"."COUNTRY_KEY" ON "intern"."COUNTRY" ("CODE")
    --  DDL for Index COUNTRY_NAME_UNIQUE
      CREATE UNIQUE INDEX "intern"."COUNTRY_NAME_UNIQUE" ON "intern"."COUNTRY" ("NAME")
    --  Constraints for Table COUNTRY
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_AREA_CHECK" CHECK (
                 Area >= 0
            ) ENABLE
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_KEY" PRIMARY KEY ("CODE") ENABLE
      ALTER TABLE "intern"."COUNTRY" MODIFY ("NAME" CONSTRAINT "COUNTRY_NAME_NOTNULL" NOT NULL ENABLE)
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_NAME_UNIQUE" UNIQUE ("NAME") ENABLE
      ALTER TABLE "intern"."COUNTRY" ADD CONSTRAINT "COUNTRY_POPULATION_CHECK" CHECK (
                 Population >= 0
            ) ENABLE

  • Using JOIN to two tables to find records NOT in second table...

    I always seem to get these types of queries wrong and need a bit of help:
    I have a table of relationships called MARKETER_ACCOUNT and another table of pending relationships called ACCOUNT_ENROLLMENT.
    I have accounts that can be enrolled with a MARKETER. They enter the ACCOUNT_ENROLLMENT table as Pending and on a certain Effective Date the go active and then move to the MARKETER_ACCOUNT table. If a relationship ends, it can end by either enrolling with another Marketer or if no pending enrollment they are assumed to be going back to the parent company.
    So I want to find all the records that came back to the parent company (i.e. they should not have a pending record in the ACCOUNT_ENROLLMENT table but have an end date in the MARKETER_ACCOUNT table:
    Select * from MARKETER_ACCOUNT M
    where M.account_no NOT IN (select E.account_no from ACCOUNT_ENROLLMENT E
    where E.effective_date between '08-DEC-2009' and '07-JAN-2010')
    and M.expiration_date between '08-DEC-2009' and '07-JAN-2010';
    This query is still running and I'm not sure where I am going wrong. I want to say GIVE me all the accounts in the MARKETER_ACCOUNT table that have an expiration date between '12/07/2009' and '01/07/2010' and where those accounts are NOT pending in the ACCOUNT_ENROLLMENT table where the effective date is for the same period.
    Any help would be greatly appreciated.
    Sean

    You could possibly try the NOT EXISTS version of the query:
    SELECT  *
    FROM    MARKETER_ACCOUNT M
    WHERE   NOT EXISTS
                    SELECT  NULL
                    FROM    ACCOUNT_ENROLLMENT E
                    WHERE   M.ACCOUNT_NO = E.ACCOUNT_NO
                    AND     E.EFFECTIVE_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY')
    AND     M.EXPIRATION_DATE BETWEEN TO_DATE('08-DEC-2009','DD-MON-YYYY') AND TO_DATE('07-JAN-2010','DD-MON-YYYY');Otherwise check out these threads:
    {message:id=1812597}
    {thread:id=863295}

  • Inner Join between two big tables

    Hi There,
    I have a situation where in which I have to write an inner join between two table of the order of (30k to 60 rows).
    My query is as simple as,
    select A.a,B.b from A ,B where A.a = B.b;
    N.B: a and b are of type varchar
    But the problem is it takes nearly 15 mins to run. Is there any better way of doing an inner join between such bigger tables?
    Thanks,
    Jose John.

    Thank you all for your help.....Indexing works....:)
    --JJ                                                                                                                                                                                                   

  • Inner join two tables

    Hi Gurus
    I want to do inner join between two tables to extract customer name
    kna1.kunnr and kna1.name1
    SELECT      FKDAT,  PKUNAG,  NAME1, VRKME, FKIMG, WERKS
    FROM        S903,KNA1 INNER JOIN KNA1
                          ON S903.PKUNAG = KNA1.KUNNR
    WHERE     (S903.WERKS = 'CO01').
    "GROUP BY wg4.S903.FKDAT, wg4.S903.PKUNAG, wg4.KNA1.NAME1, wg4.S903.VRKME, wg4.S903.FKIMG, wg4.S903.WERKS.
    So how can I join s903 with kna1
    regards
    pz

    hi,
    check the condition . i can not found your table and what is co01 .
    SELECT iFKDAT iPKUNAG iVRKME iFKIMG iWERKS mNAME1 into CORRESPONDING FIELDS OF table it
                                                                  from s903  as i
                                                                  inner join kna1 as m on iwerks = mwerks and i~werks in ( 'co01' ).
    if it works pls give me rewards point.
    Regards ,
    pankaj

  • Inner join inside a internal table loop

    Hello to all,
    I have this internal table in which i have selected some records for particular coulms. For  the rest of the colums i need to join 3 tables for the data. I had in mind, of looping the internal table and then having a inner join query and  modifying the internal table(all inside the loop) Just wanted to know, whether its a qood practice performance wise ? IF not, what are the alternatives ..
    Thanks,
    Shehryar Dahar

    shehryar,
      say You have internal table ITAB.Already some columns are updated in internal table.say A,B,C,D.
    To fill rest of the columns(E,F,G) you need inter join.
    write the inner join of the table for all entries of itab where A eq itab-A.
    LOOP ITAB.
        READ TABLE ITAB1  WITH KEY X = ITAB-X.
       IF SY-SUBRC EQ 0.
         move  ITAB record to I_FINAL.
         move itab1 records to i_final.
        append i_final.
       clear i_final.
      ENDIF. 
    ENDLOOP.
    Don't forget to reward if useful...

Maybe you are looking for