Inner join where condition?

hi all this i wrote inner join but i want for particular purchase order
what shall i add in where condtion
SELECT SINGLE
         a~ernam
         b~persnumber
         b~addrnumber
         c~smtp_addr
         INTO (l_ernam, l_persnumber,l_addrnumber,l_smtp_addr)
         FROM ( ( usr21 AS b INNER JOIN ekko AS a ON b~bname = a~ernam )
         INNER JOIN adr6 AS c ON b~addrnumber = c~addrnumber
                           AND b~persnumber = c~persnumber ).

Hi Oorvi,
just do as following.
SELECT SINGLE
         a~ernam
         b~persnumber
         b~addrnumber
         c~smtp_addr
         INTO (l_ernam, l_persnumber,l_addrnumber,l_smtp_addr)
         FROM ( ( usr21 AS b
        INNER JOIN ekko AS a ON a~bname = b~ernam )
        INNER JOIN adr6 AS c ON c~addrnumber = b~addrnumber
                                        AND c~persnumber = b~persnumber )
         *WHERE a~ebeln = p_ebeln*.                     "p_ebeln is your selection screen parameter

Similar Messages

  • Iam not getting output for inner join where condition

    the condition i have give
    TYPES:BEGIN OF TY_TAB,
          WERKS TYPE WERKS_D,
          LGORT TYPE LGORT_D,
          LGOBE TYPE LGOBE,
          NAME1 TYPE NAME1,
          END OF TY_TAB.
    DATA WA_TAB TYPE TY_TAB.
    DATA IT_TAB TYPE TABLE OF TY_TAB.
    SELECT  T001L~WERKS
            T001L~LGORT
            T001L~LGOBE
            T001W~NAME1
            INTO TABLE IT_TAB FROM T001L INNER JOIN T001W ON T001LWERKS = T001WWERKS
           WHERE  T001L~WERKS = 'amjt' and
               T001L~WERKS = 'bimi' and
               T001L~WERKS = 'biml'.
    LOOP AT IT_TAB INTO WA_TAB.
      WRITE: / WA_TAB-WERKS,WA_TAB-LGORT,WA_TAB-LGOBE,WA_TAB-NAME1.
      ENDLOOP.
    iam not getting output for this

    Well, re-read carefully your code
    WHERE T001L~WERKS = 'amjt' and
    T001L~WERKS = 'bimi' and
    T001L~WERKS = 'biml'
    - WERKS cannot be simultaneously equal to three different values, replace AND with OR ([Boolean algebra|http://en.wikipedia.org/wiki/Boolean_algebra])
    - WERKS domain does not allow lowercase, so use uppercase ([Creating Domains|http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21edf2446011d189700000e8322d00/frameset.htm])
    Regards,
    Raymond

  • INNER JOIN Where to Use

    hi,
    is there any criteria determining the usage of <b>inner join</b>, i.e no. of rows to be retrieved from the tables... can we avoid using <b>inner joins</b>...
    i hope i have cleared my query.....
    thanx in advance
    abhishek suppal

    Abhishek,
    Inner joins (when used correctly) are a GOOD thing.
    The criteria as to when to use an inner join is that the tables must have common values. For example let's look at VBAK and VBAP. The both share VBELN as their common link. And becasue VBELN is part of their keys it is very good to use an inner join if you need data from both tables.
    eg. We want to get sales Order data into TBL_SALESORDER from VBAK / VBAP
    Without Inner Join you can do it something like this:
    data: begin of tbl_vbak occurs 0,
            vbeln  like vbak-vbeln,
            kunnr  like vbak-kunnr,
            audat  like vbak-audat,
          end of tbl_vbak.
    data: begin of tbl_vbap occurs 0,
            vbeln  like vbap-vbeln,
            posnr  like vbap-posnr,
            matnr  like vbap-matnr,
            zmeng  like vbap-zmeng,
          end of tbl_vbap.
    data: begin of tbl_salesorder occurs 0,
            vbeln  like vbak-vbeln,
            kunnr  like vbak-kunnr,
            audat  like vbak-audat,
            posnr  like vbap-posnr,
            matnr  like vbap-matnr,
            zmeng  like vbap-zmeng,
          end of tbl_salesorder.
    data: l_index like st-tabix.
    select vbeln kunnr audat
           into table tbl_vbak
           from vbak.
    check sy-subrc eq 0.
    select vbeln posnr matnr zmeng
           into table tbl_vbap
           from vbap
           for all entries in tbl_vbak
           where vbeln = tbl_vbak-vbeln.
    check sy-subrc eq 0.
    sort tbl_vbap by vbeln posnr.
    loop at tbl_vbak.
      read table tbl_vbap with key vbeln = tbl_vbak-vbeln
                                   binary search.
      if sy-subrc eq 0.
        l_index = sy-tabix.
        loop at tbl_vbap from l_index.
          if tbl_vbak-vbeln ne tbl_vbap-vbeln.
            exit.
          endif.
          clear tbl_salesorder.
          move-corresponding tbl_vbak to tbl_salesorder.
          move-corresponding tbl_vbap to tbl_salesorder.
          append tbl_salesorder.
        endloop.
      endif.
    endloop.
    With an inner join you can do it like this:
    data: begin of tbl_salesorder occurs 0,
            vbeln  like vbak-vbeln,
            kunnr  like vbak-kunnr,
            audat  like vbak-audat,
            posnr  like vbap-posnr,
            matnr  like vbap-matnr,
            zmeng  like vbap-zmeng,
          end of tbl_salesorder.
    select vbak~vbeln vbak~kunnr vbak~audat
           vbap~posnr vbap~matnr vbap~zmeng
           into table tbl_salesorder
           from vbak
           inner join vbap
           on vbak~vbeln = vbap~vbeln.
    In the above example it is more efficient to use the inner join because we hit the database once. Without the inner join we hit the database twice (once for the VBAK info and the other time for the VBAP info).
    If you want to restrict the data you canuse a select option or parameter like any other SELECT statement. What you probably would not do is use the "UP TO X ROWS" clause as this will essentially limit the data from VBAP not VBAK.
    I know that this example is a very simple one and we were luck to be able to "join" the tables using their primary keys. If the "join" between the tables are not by their primary keys or by an index then you may need to reconsider using an inner join and this will cause performance problems.
    I hope this makes some sense. Let me know if you need more info, alternatively take a look at the SAP Help (F1) for SELECT.
    Cheers,
    Pat.
    PS. Kindly assign Reward Points to the posts you find helpful.

  • Query/join/where/child parent table

    query/join/where/child parent table
    hello my query below is not working for my cf application can
    you help?
    thanks
    this is my previous question so i tried to do it my self.
    tcase_req.tcase_req_id is added
    tcase.case_id=tcase_req.case_id :note that this is not part of the
    inner join in the from clause. it does not depend on the rest of
    the inner join.
    the reaon for this is that i need to get
    WHERE tcase_req.case_req_typ_cd = cwc and
    tcase_req.case_req_typ_cd = cwnc
    here is the original question
    Hello ,
    I need help again on the inner join/and conditions in the
    where clause
    I have these 2 tables tcase and tcase_req where there common
    field Is the case_id.
    tcase is the parent table and the tcase_req is the child
    table.
    (1)I wanted to add this to the from clause using the inner
    join table . what do I do and where do I put it
    (2)I then need to put a condition in the where clause to
    replace
    WHERE TCASE.CASE_NBR Like '%HPOZ%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
    by
    WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR Like
    '%CWNC%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
    Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
    is this efficient??
    thanks
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id,
    tcase_req.case_req_typ_cd
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE TCASE.CASE_NBR Like '%CWC%'and
    tcase.case_id=tcase_req.case_id
    (3)To a tcase_req
    Suffix_id are equal to = cwc and cwnc ( in the tcase_req
    table)(Suffix_id is the field that cintains the suffix cwc and cwnc
    for the tcase_req)
    also,
    this is the original query and it works fine
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR Like
    '%CWNC%')

    query/join/where/child parent table
    hello my query below is not working for my cf application can
    you help?
    thanks
    this is my previous question so i tried to do it my self.
    tcase_req.tcase_req_id is added
    tcase.case_id=tcase_req.case_id :note that this is not part of the
    inner join in the from clause. it does not depend on the rest of
    the inner join.
    the reaon for this is that i need to get
    WHERE tcase_req.case_req_typ_cd = cwc and
    tcase_req.case_req_typ_cd = cwnc
    here is the original question
    Hello ,
    I need help again on the inner join/and conditions in the
    where clause
    I have these 2 tables tcase and tcase_req where there common
    field Is the case_id.
    tcase is the parent table and the tcase_req is the child
    table.
    (1)I wanted to add this to the from clause using the inner
    join table . what do I do and where do I put it
    (2)I then need to put a condition in the where clause to
    replace
    WHERE TCASE.CASE_NBR Like '%HPOZ%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-HPOZ-CCMP'
    by
    WHERE TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE _NBR Like
    '%CWNC%'
    AND TCASE.CASE_NBR = 'DIR-2004-4269-CWC'
    Or TCASE.CASE_NBR = 'DIR-2004-4269-CWNC'
    is this efficient??
    thanks
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id,
    tcase_req.case_req_typ_cd
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE TCASE.CASE_NBR Like '%CWC%'and
    tcase.case_id=tcase_req.case_id
    (3)To a tcase_req
    Suffix_id are equal to = cwc and cwnc ( in the tcase_req
    table)(Suffix_id is the field that cintains the suffix cwc and cwnc
    for the tcase_req)
    also,
    this is the original query and it works fine
    SELECT TLA_PROP.PIN,
    TLA_PROP.ASSR_PRCL_NBR,
    TCASE.CASE_NBR,
    TLA_PROP.STR_NBR,
    TLA_PROP.STR_NBR_RNG_END,
    TLA_PROP.STR_FRAC_NBR,
    Tref_plan_area.plan_area_desc,
    TLA_PROP.STR_FRAC_NBR_RNG_END,
    TLA_PROP.STR_DIR_CD,
    TLA_PROP.STR_NM,
    TLA_PROP.STR_SFX_CD,
    TLA_PROP.STR_SFX_DIR_CD,
    TLA_PROP.STR_UNIT_TYP_CD,
    TLA_PROP.UNIT_NBR,
    TLA_PROP.UNIT_NBR_RNG_END,
    TLA_PROP.ZIP_CD,
    TLA_PROP.ZIP_CD_SFX,
    TLA_PROP.CNCL_DIST_NBR,
    TLA_PROP.PLAN_AREA_NBR,
    TLA_PROP.ZONE_REG_CD,
    TAPLC.PROJ_DESC_TXT,
    TCASE.CASE_ID,
    TCASE.CASE_NBR,
    taplc.aplc_id
    FROM TLA_PROP INNER JOIN tref_plan_area ON
    tla_prop.plan_area_nbr = tref_plan_area.plan_area_NBR INNER JOIN
    TLOC ON TLA_PROP.PROP_ID = TLOC.LOC_ID INNER JOIN TAPLC ON
    TLOC.APLC_ID = TAPLC.APLC_ID INNER JOIN TCASE ON TAPLC.APLC_ID =
    TCASE.APLC_ID
    WHERE (TCASE.CASE_NBR Like '%CWC%' or TCASE.CASE_NBR Like
    '%CWNC%')

  • Drag-n-n-drop query joins uses WHERE, not INNER JOIN syntax

    When I highlight a few tables and drag them onto the sql worksheet, it will build a select statement for me and join the tables by their foreign keys.
    That's a nice feature, thanks!
    Three questions. Is it possible to:
    1. get it to use the INNER JOIN and LEFT OUTER JOIN syntax instead of joining the tables in the WHERE clause?
    2. control the table aliases so that it will automatically use the "standard alias" for the table instead of A, B, C, etc.?
    3. get it to not put the schema name into the query?
    Thanks!
    Edited by: David Wendelken on Nov 22, 2008 1:48 PM. Grammar mistake.

    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

  • Inner join condition

    actuall i knew how to club the two database tables using innerjoin.
    ther conditios is
    select--fields----- into itab from (dtab) inner join (dtab)
    on condition
    where so and so---
    the thing is that i need to add another table data(database table).what is the code and syntax.
    please reply with example in detail.thanku.

    Hi,
    Better to use FOR ALL ENTRIES, dont use inner join.
    refer below code
    *&      Form  sub_read_mara                                            *
    This form will Select the material number material type material    *
    group & batch management indicator from table mara using given      *
    material number                                                     *
    FORM sub_read_mara .
    *--Select query to pick the material number material group material type
    and batch management from table MARA
      SELECT matnr                            "Material Number
             mtart                            "Material Type
             matkl                            "Material Group
             xchpf                            "Batch Management
             FROM mara                        "Material Master
             INTO TABLE i_mara
             WHERE matnr IN s_matnr
             AND   mtart IN s_mtart
             AND   matkl IN s_matkl .
    *--Check Subrc
      IF sy-subrc <> 0.
    *--No data found for the given selection criteria.
        MESSAGE i001.
        LEAVE TO LIST-PROCESSING.
      ELSE.
    *--Sort table by Material Number
        SORT i_mara BY matnr.
      ENDIF.
    ENDFORM.                                  "sub_read_mara
    *&      Form  sub_read_marc                                            *
    This form will Select the material number plant purchasing group &  *
    MRP controller from table MARC using given material number plant &  *
    purchasing group.                                                   *
    FORM sub_read_marc .
      IF NOT i_mara[] IS INITIAL.
    *--Select query to pick the material number plant purchasing group &
    MRP controller from table MARC
        SELECT matnr                            "Material Number
               werks                            "Plant
               ekgrp                            "Purchasing Group
               dispo                            "MRP Controller
               FROM marc                        "Material Master
               INTO TABLE i_marc
               FOR ALL ENTRIES IN i_mara
               WHERE matnr = i_mara-matnr
               AND werks IN s_werks
               AND ekgrp IN s_ekgrp
               AND dispo IN s_dispo.
    *--Check Subrc
        IF sy-subrc <> 0.
          MESSAGE i001.
          LEAVE TO LIST-PROCESSING.
        ELSE.
    *--Sort table by Material Number Plant
          SORT i_marc BY matnr werks.
        ENDIF.
      ENDIF.
    ENDFORM.                                  "sub_read_marc
    Regards,
    Prashant

  • The process time between INNER JOIN and join in WHERE clause

    as u know, there are 2 kind of join
    SELECT *
    FROM tableA
    INNER JOIN tableB
    ON tableA.ID= tableB.ID
    WHERE ....
    and
    SELECT *
    FROM tableA, tableA
    WHERE tableA.ID = tableB.ID
    AND ....
    I find the first one is faster in MS SQL Server.
    But i test them in oracle and i find that it is the same. Is it correct?

    Who knows why SQL Server shows different timings. Perhaps it's just cos it's not good at knowing that the two things are the same.
    The only difference in timing as far as Oracle is concerned is the time it takes to parse the syntax of the query, which will be nanoseconds. The execution time of two equivalent queries will not differ based on the factor of the syntax used.

  • Inner Join Condition For  Database Tables in JDBC Adapter

    Hi
    Is there any restriction for Number of database tables to Write Inner join Condition in JDBC.
    Thanks

    Venkat,
    No there is no restriction in Inner join. If your query executes perfectly in target Database then the same query will exceute perfectly while calling through XI.
    Best regards,
    raj.

  • SELECT INNER JOIN vs WHERE

    Hello
    What is the best programming, putting selection in the inner join or in where clause.  Below is some sample code that works but wondering if C~statu='X' would have been better in the Where part of the statement in stead as part of the inner join?  Maybe don't need the Where in this select statment just code in the inner joins?
    SELECT algnum abdatu btanum btapos atbnum btbpos b~werks
             blgort bmatnr bmeins bmaktx bvsolm bvltyp b~vlpla
             b~nlpla
        INTO TABLE gt_ltak
        FROM ltak AS a
        INNER JOIN ltap AS b ON blgnum = algnum AND
                                                 btanum = atanum
        INNER JOIN lrf_wkqu AS c ON clgnum = algnum     AND
                                                         c~bname = sy-uname AND
                                                         cqueue = aqueue    AND
                                                         c~statu = 'X'
        INNER JOIN zis_prog_vars AS d ON d~pgm = 'ZRF_TRANS_03_0100' AND
                                                                  d~fld = l_priority                            AND
                                                                  dval1 = atbpri
        WHERE a~lgnum = '170'        AND
                     a~tanum = '0000001399'.

    Hi,
    Herewith the corrected version:
    SELECT a~lgnum a~bdatu b~tanum b~tapos a~tbnum b~tbpos b~werks
           b~lgort b~matnr b~meins b~maktx b~vsolm b~vltyp b~vlpla b~nlpla
      INTO TABLE gt_ltak
      FROM ltak AS a
    INNER JOIN ltap AS b ON b~lgnum = a~lgnum AND
                             b~tanum = a~tanum  
    INNER JOIN lrf_wkqu AS c ON c~lgnum = a~lgnum AND
                                 c~queue = a~queue AND
    INNER JOIN zis_prog_vars AS d ON d~val1 = a~tbpri
    WHERE a~lgnum = '170'
       AND a~tanum = '0000001399'
       AND c~bname = sy-uname
       AND c~statu = 'X'
       AND d~pgm = 'ZRF_TRANS_03_0100'
       AND d~fld = l_priority.
    Kr,
    m.

  • For All Entries is NOT better than INNER JOIN in most cases

    I quote from Siegfried Boes' excellent post here: Will writing an inner join be better or creating a view?
    For all the FOR ALL ENTRIES lovers ... there is no proof for these reappearing recommendation.
    There is nearly nobody who receives forum points, who recommends FOR ALL ENTRIES instead of Joins. What is the reason ???
    It is easier to prove the opposite. A Join is a nested loop inside the database, a FOR ALL ENTRIES is partly outside of the database. FOR ALL ENTRIES works in blocks, joins on totals.
    FOR ALL ENTRIES are not recommded on really large tables, because the chances are too high that
    too many records are transferred.
    People prefer FOR ALL ENTRIES, because JOINs are not so easy to understand. Joins can go wrong, but with a bit of understanding they can be fixed.
    Some Joins are slow and can not be fixed, but then the FOR ALL ENTRIES would be extremely slow.
    There are several kinds of views:
    - projection views, i.e. only one table involved just fields reduced
    - join views, several tables, joins conditions stored in dictionary
    - materialized views, here the joined data are actually stored in the database. Storing and synchronisation has to be done manually.
    Only the last one creates real overhead. It should be the exception.
    Join Views and Joins are nearly identical. The view is better for reuse. The join is better in complicated, becuase if the access goes wrong, it can often be fixed by adding a hint. Hints can not be added to views.
    Abraham Bukit  points out:
    If it is cluster table, (you can't use join). If it is buffered table, I would also say avoid join.
    If they all are transaction table which are not buffered and are not cluster tables.  
    He further supports Siegfried's statement that FAE is easier to undestand than INNER JOINs.
    Thomas Zloch says, regarding buffered tables:
    At least think twice, maybe compare runtimes if in doubt. 
    So, unless someone has some EVIDENCE that FOR ALL ENTRIES is better, I don't think we want to see this discussed further.
    Kind regards
    Matt

    To give food for thought here's an example I  gave in a thread:
    If you have a statement like
    SELECT ... FOR ALL ENTRIES IN FAE_itab WHERE f = FAE_itab-f.
    SAP sends it to the database depending how the parameter rsdb/prefer_union_all is set:
    rsdb/prefer_union_all = 0 =>
    SELECT ... WHERE f = FAE_itab[1]-f
              OR    f = FAE_itab[2]-f
              OR    f = FAE_itab[N]-f
    You have some influence  of the generated statement type: Instead of OR'ed fields an IN list can be used
    if you have only a single coulmn N to compare:
    rsdb/prefer_in_itab_opt parameter:
    SELECT ... WHERE f IN (itab[1]-f, itab[2]-f, ..., itab[N]-f)
    rsdb/prefer_union_all = 1 =>
    SELECT ... WHERE f = FAE_itab[1]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[2]-f
    UNION ALL SELECT ... WHERE f = FAE_itab[N]-f
    see: Note 48230 - Parameters for the SELECT ... FOR ALL ENTRIES statement
    As you can see for the 2nd parameter several statements are generated and combined with a UNION ALL,
    the first setting generates statements with OR's (or uses IN  if possible) for the entries in FAE_itab.
    I give you a little example here (my parameters are set in a way that the OR's are translated to IN lists; i traced the execution in ST05)
    Select myid into table t_tabcount from mydbtable
      for all entries in t_table    " 484 entries
        where myid = t_table-myid .
    ST05 trace:
    |Transaction SEU_INT|Work process no 0|Proc.type  DIA|Client  200|User |
    |Duration |Obj. name |Op.    |Recs.|RC    |Statement|
    | 640|mydbtable |PREPARE|   |  0|SELECT WHERE "myid" IN ( :A0 , :A1 , :A2 , :A3 , :A4 ) AND "myid" = :A5|
    | 2|mydbtable |OPEN   |   |  0|SELECT WHERE "myid" IN ( 1 , 2 , 3 , 4 , 5 ) AND "myid" = 72 |
    | 2.536|mydbtable |FETCH  |    0|  1403|   |
    | 3|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 6 , 7 , 8 , 9 , 10 ) AND "myid" = 72 |
    | 118|mydbtable |FETCH  |  0|  |
    | 2|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 11 , 12 , 13 , 14 , 15 ) AND "myid" = 72     |
    | 3|mydbtable |REOPEN |  |  0|SELECT WHERE "myid" IN ( 475 , 476 , 477 , 478 , 479 ) AND "myid" = 72  |
    | 94|mydbtable |FETCH  | 0| 1403|   |
    | 2|mydbtable |REOPEN |   |  0|SELECT WHERE "myid" IN ( 480 , 481 , 482 , 483 , 484 ) AND "myid" = 72 |
    You see the IN list contained 5 entries each , wich made up about 97 statements for all 484 entries.
    For every statment you have a single fetch operation wich means a separate access to the database.
    If you would replace the FAE with a join you would only have one fetch to the database.
    With the example above we can derive these observations:
    1. From database point of view these settings kill performance when you access a big table and/or have a lot of entries or columns in your FAE_itab. Furthermore, you hide information what data you will access
    at all and thus you block the database from creating a more efficient execution plan because it DOESN'T KNOW wich data you will select in the next step. I.e. it may be more efficient to scan the table in one shot instead of having many index accesses - but the database can make this decision only if it can examine ONE statement that has ALL the information of what data to retrieve.
    2. A second impact is that with every statement execution you trigger the allocation of database resources
    wich will contribute to the overhead described above.
    Said that, FAE  can never be a replacement for joining big tables (think of having a table with thousands of records in a FAE table )
    Edited by: kishan P on Nov 2, 2010 2:16 PM - Format Fixed

  • 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

  • Report - INNER JOIN Problem

    Hi,
    In my report List of Block Customer's, INNER JOIN is not working..
    Code:----
    SELECT DISTINCT M1KUNNR M1KTOKD M1NAME1 M1CASSD M1AUFSD M1LIFSD M1~FAKSD INTO CORRESPONDING FIELDS OF TABLE ITAB
                        FROM KNA1 AS M1 INNER JOIN KNVV AS M2 ON M1KUNNR = M2KUNNR
                                               WHERE M1~KTOKD IN ('0001' , 'KTOKD')
                                                AND M1~CASSD EQ 'X'
                                                 OR M1~AUFSD NE ''
                                                 OR M1~LIFSD NE ''
                                                 OR M1~FAKSD NE ''
                                                 OR (M2~AUFSD NE ''
                                                 OR M2~LIFSD NE ''
                                                 OR M2~FAKSD NE ''
                                                 OR M2~CASSD EQ 'X'.
    Here, condition on 0001 is not matching..
    Plz tell me, what is the problem in it..
    Thanks
    Edited by: Prince Kumar on Oct 20, 2008 9:37 AM

    hi,
    please use " FOR ALL ENTRIES " as it is better performance wise also rather then inner joins
    and for syntax refer this code:
    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.
    PARAMETERS p_city TYPE spfli-cityfrom.
    TYPES: BEGIN OF entry_tab_type,
             carrid TYPE spfli-carrid,
             connid TYPE spfli-connid,
           END OF entry_tab_type.
    DATA: entry_tab   TYPE TABLE OF entry_tab_type,
          sflight_tab TYPE SORTED TABLE OF sflight
                           WITH UNIQUE KEY carrid connid fldate.
    SELECT carrid connid
           FROM spfli
           INTO CORRESPONDING FIELDS OF TABLE entry_tab
           WHERE cityfrom = p_city.
    SELECT carrid connid fldate
           FROM sflight
           INTO CORRESPONDING FIELDS OF TABLE sflight_tab
           FOR ALL ENTRIES IN entry_tab
           WHERE carrid = entry_tab-carrid AND
                 connid = entry_tab-connid.
    thanks and regards
    RAHUL

  • Query related to inner join V/S all entries........

    Hi all,
    I have a dought ...related to join and all entries
    Which one will be the better as per performance prospective :
    1>For all entries
    or
    2> using inner join condition
    i am combining 2 tables ...
    but in my where clause is having 6-7 condition if i used inner join concept...
    Please let me know thanks for the help...in advance
    regards
    Amit

    Check Re: Multiple Table Join instead of Nested Selects? I wrote a program that compares the performance of a join against for all entries. The join won. But the best thing to do is for you test and compare both methods for your particular situation.
    In a select, the most important factor is the use of an index.
    Rob

  • How to use INNER JOIN in such case

    when i program as below[CASE1]. the code is able to active.
    CASE1:
    ==========================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                  CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE)
                WHERE BUKRS = I_BUKRS.
      ENDFORM.                   
    ===========================
    but when I need to INNER JOIN another table [CASE2]
    CASE2:
    =======================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                    CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE) AS G INNER JOIN BKPF AS H
                   ON GBUKRS = HBUKRS
                WHERE G~BUKRS = I_BUKRS.
      ENDFORM.          
    =================================
    Syntax error:
    Wrong expression "INNER" in FROM clause. WHERE condition.
    Can anybody help me to solve the problem.
    My requirement is to use INNER JOIN with variable table

    hi slam,
    chk this sample code.
    hi,
    table emp
    empno name
    a sasi
    b xxx
    c yyy
    table sal
    empno salary
    a 1000
    b 2000
    Inner join
    select eempno ename
    s~sal
    into table int_table
    from emp as e
    inner join sal as s
    on
    eempno = sempno.
    if you made inner join between table a and b by emp no
    the selection retrives only if the condition satisfy the output will be
    a sasi 1000
    b xxx 2000
    rgds
    anver
    if hlped mark points
    Message was edited by: Anversha s

  • Sequence of inner join

    Will the sequence of inner join...
    eg. joining kna1, knb1, bkpf, bsid
    affect performance?
    or does it matter when choosing the field to be in the where clause from one of the 4 tables affect performance.. when considering the use of index?

    Hi Charles,
    the system will take care of this. Important is the correct use of join conditions. Make sure that the relation is 1 : n for any join. If you have two rows in one table matching 3 rows in the second table, the database will retrieve all possible combinations ( 6 rows) This causes unnecessary overhead, memory space waste, performance issues, duplicates and confusion.
    A good rule is to join from more to less record, i.e.
    select vkan~vbeln vbap~posnr vbap~menge
      into corresponding fields of table ...
      from vbap
      join vbak
        on vbap~vbeln
         = vbak~vbeln
    where ...
    Regards,
    Clemens

Maybe you are looking for