Join of thre tables - index VLPMA, LIPS, VBUP

Hello,
I woud like to ask you about help. I have to do performance tuning of one program wich runs very long. I noticed, that the biggest problem is in join of three tables LIKP, LIPS and VBUP.  I replaced original table LIKP by index table VLPMA and it helped  - mainly when a material is filled in on select-option s_matnr. But the run is still very long. DO you have any idea what more could I do with the select? Ist there any index table similar to lips?
select lipslgort vlpmavbeln vlpmaposnr vlpmamatnr vlpma~kunnr
        lipslgmng lipsmeins into table ilips
        from vlpma inner join vbup on vbupvbeln eq vlpmavbeln and
                                     vbupposnr eq vlpmaposnr
                  inner join lips on vlpmavbeln eq lipsvbeln and
                                     vlpmaposnr eq lipsposnr
         where vlpma~matnr in s_matnr and
               lips~lgort in s_lgort and
               vbup~wbsta ne 'C' and
               vbup~kosta ne 'C' .
Thanks a lot
Miloslav Pudil

Since VBUP is not in the list of selected fields, it doesn't need to be included in the join. Instead, it can be in an EXISTS subquery in the WHERE clause. This is logically the same but the join is on two tables only. Also incorporating the other idea from Dave L. of not using NOT should help further.
select lips~lgort vlpma~vbeln vlpma~posnr vlpma~matnr vlpma~kunnr lips~lgmng lips~meins
into table ilips
from vlpma
   inner join lips on vlpma~vbeln eq lips~vbeln and vlpma~posnr eq lips~posnr
where vlpma~matnr in s_matnr
   and  lips~lgort in s_lgort
   and EXISTS ( SELECT *
                          FROM VBUP
                          WHERE vbeln eq vlpma~vbeln
                                and posnr eq vlpma~posnr
                                and wbsta IN (' ', 'A', 'B')
                                and kosta IN (' ', 'A', 'B') ).
Edited by: Erik Peterson on Dec 1, 2009 9:05 AM

Similar Messages

  • Joinning of three tables

    hi can u guys plss tell me how to join three tables!! my requirement wants me to do some kind of join on three tables!!
    points promised!! thanx in advance!!

    hi,
    check this sample code
    TABLES : KNA1,KNVV.
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-101.
    select-options : p_kunnr like kna1-kunnr.
    SELECTION-SCREEN : END OF BLOCK b1.
    data :BEGIN OF T_KNA1 OCCURS 0,
          KUNNR LIKE KNA1-KUNNR,
          LAND1 LIKE KNA1-LAND1,
          NAME1 LIKE KNA1-NAME1,
          END OF T_KNA1.
    DATA :BEGIN OF T_KNVV OCCURS 0,
          KUNNR LIKE KNA1-KUNNR,
          VKORG LIKE KNA1-VKORG
          VTEWG LIKE KNA1-VTEWG,
          END OF T_KNVV.
    FINAL INTERNAL TABLE
    DATA : BEGIN OF T_FINAL OCCURS 0,
           KUNNR LIKE KNA1-KUNNR,
          LAND1 LIKE KNA1-LAND1,
          NAME1 LIKE KNA1-NAME1,
          VKORG LIKE KNA1-VKORG
          VTEWG LIKE KNA1-VTEWG,
          END OF T_FINAL.
    START-OF-SELECTION
    SELECT KUNNR LAND1 NAME1 FROM KNA1 INTO TABLE T_KNA1 WHERE KUNNR IN P_KUNNR
    IF SY-SUBRC = 0.
    select KUNNR
            VKORG VTEWG
            from KNVV
            into CORRESPONDING FIELDS OF table T_KNVV
            for all entries in T_KNA1
            where KUNNR = T_KNA1-KUNNR.
    ENDIF.
    LOOP AT T_KNA1.
    MOVE T_KNA1-KUNNR TO T_FINAL-KUNNR.
    MOVE T_KNA1-LAND1 TO T_FINAL-LAND1.
    MOVE T_KNA1-NAME1 TO T_FINAL-NAME1.
    READ TABLE T_KNVV WITH KEY KUNNR = T_KNA1-KUNNR.
    IF SY-SUBRC = 0.
    MOVE T_KNVV-VKORG TO T_FINAL-VKORG.
    MOVE T_KNVV-VTEWG TO T_FINAL-VTEWG.
    ENDIF.
    APPEND T_FINAL.
    CLEAR T_FINAL.
    ENDLOOP.
    LOOP AT T_FINAL.
    WRITE: (FIELDS U WANT TO DISPLAY)
    ENDLOOP.
    regards
    siva

  • 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

  • Left join query with join of three tables

    I'm trying to build a query which has me stumped. Most of the query is fairly straightforward but I've run into an issue I'm not sure how to solve.
    Background:
    We have actions stored in i_action.
    We have the available attributes for each type of action. The available attributes for each action are described in shared_action_attribute. Each type of action may have up to three attributes or none at all.
    We have the values stored for the attributes in i_attribute_value.
    A written example:
    We have a transfer action (action_code B4). The entry of the B4 action into i_action records the fact that the transfer occurred and the date on which it occurred. The available attributes for a transfer action are the receiving function code, the receiving unit number, and the transfer reason code. These available attribute types and their order are stored in shared_action_attribute. The actual values of the attributes for a specific transfer action are stored in i_attribute_value.
    Now i_action and i_attribute_value can be directly linked through action_seq in i_action and ia_action_seq in i_attribute_value. A left join built between these two tables provides results for all actions (including actions which have no attributes) and attribute values (see query 1 below).
    There are two issues. First, I only want the first two attributes. In order to specify the first two attributes, I also have to link i_attribute_value to shared_action_attribute (which is where the order is stored). I can build a simple query (without the left join) linking the three tables but then actions with no attributes would be excluded from my result set (see query 2 below).
    The second issue is that I would actually like one row returned for each action with first_attribute and second_attribute as columns instead of two rows.
    The final query will be used to create a materialized view.
    Here are the tables and examples of what's stored in them:
    TABLE i_action
    Name Type
    ACTION_SEQ NUMBER(10)
    ACTION_DATE DATE
    ACTION_CODE VARCHAR2(3)
    DELETED VARCHAR2(1)
    EXAMPLE ROWS
    ACTION_SEQ ACTION_DATE ACTION_CODE DELETED
    45765668 09-OCT-09 B2 A
    45765670 09-OCT-09 BA A
    45765672 09-OCT-09 B6 A
    45765673 09-OCT-09 B4 A
    45765674 09-OCT-09 G1 A
    45765675 09-OCT-09 M3 A
    TABLE i_attribute_value
    Name Type
    IA_ACTION_SEQ NUMBER(10)
    SACTATT_SACT_CODE VARCHAR2(3)
    SACTATT_SAT_TYPE VARCHAR2(3)
    VALUE VARCHAR2(50)
    EXAMPLE ROWS
    IA_ACTION_SEQ SACTATT_SACT_CODE SACTATT_SAT_TYPE VALUE
    45765668 B2 ACO 37B
    45765670 BA ROA D
    45765670 BA ROR P
    45765672 B6 CAT C
    45765673 B4 RFC E
    45765673 B4 TRC P
    45765673 B4 RUN 7
    45765674 G1 SS 23567
    45765674 G1 ASG W
    TABLE shared_action_attribute
    Name Type
    SACT_CODE VARCHAR2(3)
    SAT_TYPE VARCHAR2(3)
    ORDER NUMBER(2)
    TITLE VARCHAR2(60)
    EXAMPLE ROWS
    SACT_CODE SAT_TYPE ORDER TITLE
    B2 ACO 1 Office code
    BA ROR 1 Reason for reopen
    BA ROA 2 Reopen authority
    B6 CAT 1 Category
    B4 RFC 1 Receiving function code
    B4 RUN 2 Receiving unit code
    B4 TRC 3 Transfer reason code
    G1 SS 1 Staff sequence
    G1 ASG 2 Assignment reason
    QUERY 1:
    This is my current query along with its results. Most of it is straightforward select but one column is populated using the last_value analytical function (thanks to you guys). The last column in the below view stores the attribute value. What I want is to replace that single column with two columns named first_attribute and second_attribute and to eliminate any other attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = 'G1'
    AND iav.sactatt_sat_type = 'SS'
    THEN VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    ia.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,
    value
    FROM i_action ia LEFT JOIN i_attribute_value iav
    ON iav.ia_action_seq = ia.action_seq
    WHERE ia.deleted = 'A';
    ACTION_SEQ ACTION_DA COD STAFF_SEQ VALUE
    45765668 09-OCT-09 B2 67089 37B
    45765670 09-OCT-09 BA 67089 D
    45765670 09-OCT-09 BA 67089 P
    45765672 09-OCT-09 B6 67089 C
    45765673 09-OCT-09 B4 67089 E
    45765673 09-OCT-09 B4 67089 P
    45765673 09-OCT-09 B4 67089 7
    45765674 09-OCT-09 G1 23567 23567
    45765674 09-OCT-09 G1 23567 W
    45765675 09-OCT-09 M3 23567
    QUERY 2:
    This query limits to the first two attributes but it also drops actions which have no attributes and it still creates multiple rows for each action instead of a single row with two columns for the attributes.
    SELECT ia.action_seq, ia.action_date, ia.action_code cod,
    NVL
    (LAST_VALUE (CASE
    WHEN ia.action_code = 'G1'
    AND iav.sactatt_sat_type = 'SS'
    THEN VALUE
    WHEN ia.action_code IN ('A0', 'A1')
    THEN '67089'
    END IGNORE NULLS
    ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
    ia.serial_number, ia.action_seq),
    '67089'
    ) staff_seq,
    value
    FROM shared_action_attribute saa, ims_action ia, ims_attribute_value iav
    WHERE iav.ia_action_seq = ia.action_seq
    AND iav.sactatt_sact_code = saa.sact_code
    AND iav.sactatt_sat_type = saa.sat_type
    AND saa.display_order IN ('1','2')
    AND ia.deleted = 'A';
    ACTION_SEQ ACTION_DA COD VALUE
    45765668 09-OCT-09 B2 67089 37B
    45765670 09-OCT-09 BA 67089 D
    45765670 09-OCT-09 BA 67089 P
    45765672 09-OCT-09 B6 67089 C
    45765673 09-OCT-09 B4 67089 E
    45765673 09-OCT-09 B4 67089 7
    45765674 09-OCT-09 G1 23567 23567
    45765674 09-OCT-09 G1 23567 W
    I found this pretty complex to try to write out - I hope I've been clear.
    Thanks so much!

    Ok, here's more information with a simplified question. I figured out the syntax for building my query with the three tables. My final query returns multiple rows (multiple attributes per action). Instead of multiple rows, I'd like two columns (first_attribute, and second_attribute) in a single row (I only need the first two attributes).
    Here's the action table:
    CREATE TABLE I_ACTION
      ACTION_SEQ               NUMBER(10)           NOT NULL,
      ACTION_DATE              DATE,
      ACTION_CODE              VARCHAR2(3 BYTE)     NOT NULL,
      DELETED                  VARCHAR2(1 BYTE),
    );With the following rows added:
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765668, '09-oct-2009', 'B2', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765670, '09-oct-2009', 'BA', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765672, '09-oct-2009', 'B6', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765673, '09-oct-2009', 'B4', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765674, '09-oct-2009', 'G1', 'A');
    Insert into I_ACTION (ACTION_SEQ, ACTION_DATE, ACTION_CODE, DELETED)
                  Values (45765675, '09-oct-2009', 'M3', 'A');
    COMMIT;The attribute table is:
    CREATE TABLE I_ATTRIBUTE_VALUE
      IA_ACTION_SEQ          NUMBER(10)             NOT NULL,
      SACTATT_SACT_CODE      VARCHAR2(3 BYTE)       NOT NULL,
      SACTATT_SAT_TYPE       VARCHAR2(3 BYTE)       NOT NULL,
      VALUE                  VARCHAR2(50 BYTE),
    );With the following rows:
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765668, 'B2', 'ACO', '37B');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765670, 'BA', 'ROR', 'P');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765670, 'BA', 'ROA', 'D');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765672, 'B6', 'CAT', 'C');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'RFC', 'E');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'RUN', '7');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765673, 'B4', 'TRC', 'P');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765674, 'G1', 'SS', '23567');
    Insert into I_ATTRIBUTE_VALUE (IA_ACTION_SEQ, SACTATT_SACT_CODE, SACTATT_SAT_TYPE, VALUE)
                           Values (45765674, 'G1', 'ASG', 'W');
    COMMIT;And finally, the shared table:
    CREATE TABLE SHARED_ACTION_ATTRIBUTE
      SACT_CODE      VARCHAR2(3 BYTE)               NOT NULL,
      SAT_TYPE       VARCHAR2(3 BYTE)               NOT NULL,
      TITLE          VARCHAR2(25 BYTE)              NOT NULL,
      DISPLAY_ORDER  NUMBER(2)                      NOT NULL
    );With the following rows:
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'RFC', 'Y', 'Rcv. Function Code', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'CAT', 'Y', 'Category', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('G1', 'SS', 'Y', 'Staff Name', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B2', 'ACO', 'Y', '"Other" Office Code', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'RUN', 'Y', 'Receiving Unit Number', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'LEP', 'N', 'LEP Issue/Sub Category', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B4', 'TRC', 'Y', 'Transfer Reason Code', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B6', 'NEP', 'N', 'NEP Issue', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('G1', 'ASG', 'Y', 'Assignment Reason', 2);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('B2', 'MSN', 'S', 'Machine Serial Number', 3);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('BA', 'ROR', 'Y', 'Reopen Reason', 1);
    Insert into SHARED_ACTION_ATTRIBUTE (SACT_CODE, SAT_TYPE, TITLE, DISPLAY_ORDER)
                                 Values ('BA', 'ROA', 'Y', 'Reopen Authority', 2);
    COMMIT;Now, this is my current query (it's changed from my first post):
    SELECT ia.action_seq, ia.ici_charge_inquiry_seq, ia.action_date,
           ia.serial_number, ia.reporting_office, ia.reporting_function,
           ia.reporting_unit, ia.action_code, ia.machine_serial_number,
           NVL
              (LAST_VALUE (CASE
                              WHEN ia.action_code = 'G1'
                                 THEN VALUE
                              WHEN ia.action_code IN ('A0', 'A1')
                                 THEN '67089'
                           END IGNORE NULLS
                          ) OVER (PARTITION BY ia.ici_charge_inquiry_seq ORDER BY ia.action_date,
                ia.serial_number, ia.action_seq),
               '67089'
              ) staff_seq,
           (CASE
              WHEN display_order = '1'
              THEN VALUE
           END) first_attribute,
           (CASE
              WHEN display_order = '2'
              THEN VALUE
           END) second_attribute
      FROM ims_action ia
      LEFT JOIN ims_attribute_value iav
           ON iav.ia_action_seq = ia.action_seq
      LEFT JOIN shared_action_attribute
           ON sactatt_sact_code = sact_code
         AND sactatt_sat_type = sat_type
    WHERE ia.deleted = 'A';Which gives me the following results:
    ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE   
      45765668 09-OCT-09 B2  67089     37B                                
      45765670 09-OCT-09 BA  67089                     D                  
      45765670 09-OCT-09 BA  67089     P                                  
      45765672 09-OCT-09 B6  67089     C                                  
      45765673 09-OCT-09 B4  67089     E                                  
      45765673 09-OCT-09 B4  67089                     7                  
      45765673 09-OCT-09 B4  67089                                        
      45765674 09-OCT-09 G1  23567                     W                  
      45765674 09-OCT-09 G1  23567     23567                              
      45765675 09-OCT-09 M3  23567                                       The result I WANT is similar but I want the two separate attribute columns on one row as such:
    ACTION_SEQ ACTION_DA ACT STAFF_SEQ FIRST_ATTRIBUTE SECOND_ATTRIBUTE   
      45765668 09-OCT-09 B2  67089     37B                                
      45765670 09-OCT-09 BA  67089     P               D                  
      45765672 09-OCT-09 B6  67089     C                                  
      45765673 09-OCT-09 B4  67089     E               7                  
      45765674 09-OCT-09 G1  23567     23567           W                  
      45765675 09-OCT-09 M3  23567                          Thanks so much!

  • 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

  • Joins in three tables

    I want to List all authors who have published books with both Random House and Fawcett Publishers.
    following are the table structures.
    Author Table
    AuthorNum     ,AuthorLast     ,AuthorFirst
    Book Table
    BookCode     Title     PublisherCode     Type     Price     Paperback
    Publisher Table
    PublisherCode     PublisherName     City
    Wrote Table
    BookCode     AuthorNum      Sequence
    I wrote the following query :
    SELECT DISTINCT Author.AuthorNum, Author.AuthorLast, Author.AuthorFirst
    FROM Author INNER JOIN (Book INNER JOIN Wrote ON Book.BookCode=Wrote.BookCode) ON Author.AuthorNum=Wrote.AuthorNum
    WHERE ((Book.PublisherCode) In ("FA","RH"));
    but its not working as expected.It is giving me authors who have published with Random House and Fawcett Publishers and also giving the authors who have published with any one of them.. But I need those authors who have published with both of the above publishers.
    Thanks.
    Edited by: Hardik Shah on Oct 12, 2010 9:22 PM
    Edited by: Hardik Shah on Oct 12, 2010 9:25 PM

    Hi,
    You need some condition that says a single author must have both publishers.
    You can user the COUNT (DISTINCT ...) fucntion to see how many different publishers there are, like this:
    SELECT     AuthorNum
    ,     AuthorLast
    ,     AuthorFirst
    FROM     Author
    WHERE     AuthroNum  IN (
                     SELECT    w.AuthorNum
                     FROM         Book     w
                     JOIN         Wrote     b  ON     b.BookCode     = w.BookCode
                     WHERE         b.PublisherCode     IN ('FA', 'RH')       -- Note: 2 items in IN-list
                     GROUP BY  w.AuthorNum
                     HAVING    COUNT (DISTINCT b.PublisherCode) = 2  -- Same as number of items in IN-list above
    ;If you'd like to post some sample data (CREATE TABLE and INSERT statements), and the results you want from that data, then I could test it.
    You could get the same results using a 3-way JOIN, and no sub-query.
    Remember to use single-quotes around string literals, such as 'FA'.
    You'll get better answers faster if you post SQL questions like this in the SQL forum:
    PL/SQL

  • Getting no result by joining three tables in BMM

    Hi all,
    I have a requirement where I have a fact table and two ailas dimension table.
    Let say fact is w_account_f and dimension ailas dim_w_account_d_trans and dim_w_account_d_sal of w_account_d table
    I have join in physical layer
    w_account_f ----> dim_w_account_d_trans with forgin key join
    w_account_f ----> dim_w_account_d_sal with forgin key join
    In BMM i have join these three table but given content level filter in dimension like
    dim_w_account_d_trans.tans_col = 'active'
    dim_w_account_d_sal.sal > 4000
    when i am trying to pull the report from all three table
    w_account_f, dim_w_account_d_trans, dim_w_account_d_sal
    its not giving any result where as when i trying to pull report with fact any one dimension its giving me result.
    can anyone help me in finding the soulting how to get the data by joining all these three tables.

    Hi,
    Take the physical query with all three tables selected. Run the query in sql developer, remove the joins one by one and check where it fails. Modify the rpd model accordingly.
    Regards,
    Dpka

  • Join query for three tables

    Hi i have got this query that is a join of two tables but i need join for three tables i need the extended query
    select aauthlname aauthlnam aauthfname aauthfnam aisbn btitle
      from ( bsauthors as a inner join bsbook as b on aisbn = bisbn )
      into corresponding fields of table books
      where aauthlname like authorlname or aauthfname like authorfname
      order by aauthlname aauthfname a~isbn.

    Hi pavan
    Plz try the following querry for joins on three tables :
    " Customize it to ur requirements and tablenames
    Parameters : b type mara-matnr.
    select xmatnr xmtart xmatkl ywerks ylgort zmaktx
    into corresponding fields of table itab
         from (  ( mara as x inner join mard as y on xmatnr = ymatnr )
    inner join makt as z on xmatnr = zmatnr ) where x~matnr = a and
    y~werks
    = b .
    Plz see that there is atleast one field common between the three tables u want to use.
    Regards
    Pankaj

  • Generate a report with three table

    hi Friends,
    i have three table
    1-
    CREATE TABLE "TRANSACTION_DETAILS"
    (     "S_NO" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
         "VEHICLE_NO" VARCHAR2(20),
         "ITEM_NAME" VARCHAR2(500),
         "DESCRIPTION" VARCHAR2(4000),
         "QTY" NUMBER,
         "RATE" NUMBER,
         "AMOUNT" NUMBER,
         CONSTRAINT "TRANSACTION_DETAILS_CON" PRIMARY KEY ("S_NO") ENABLE
    2-
    CREATE TABLE "LAB_WORK_DTL"
    (     "ID" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
    "VEHICLE_NO" VARCHAR2(20),
         "WORK_DETAIL" VARCHAR2(4000),
         "LABOUR_AMT" NUMBER,      
         CONSTRAINT "LAB_WORK_DTL_PK" PRIMARY KEY ("ID") ENABLE
    3-
    CREATE TABLE "JOB_CARD_DETAILS"
    (     "ID2" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
         "VEHICLE_NO" VARCHAR2(20),
         "AMOUNT" NUMBER,
         CONSTRAINT "JOB_CARD_DETAILS_CON" PRIMARY KEY ("ID2") ENABLE
    i want to generate a Report of total amout of bill No Like
    BILL_NO,BILL_DATE,VEHICLE_NO,SUM(AMOUNT) ,SUM(LABOUR_AMT),SUM(AMOUNT)
    I AM USING
    select a.BILL_NO,a.BILL_DATE,a.PARTY_NAME,a.VEHICLE_NO,SUM(a.AMOUNT),SUM(b.LABOUR_AMT),SUM(c.AMOUNT) from TRANSACTION_DETAILS a,LAB_WORK_DTL b,JOB_CARD_DETAILS c where a.PARTY_NAME =b.PARTY_NAME and a.PARTY_NAME=c.PARTY_NAME and a.PARTY_NAME =:P38_PARTY_NAME group by a.bill_no,a.BILL_DATE,a.PARTY_NAME,a.VEHICLE_NO,b.bill_no,b.BILL_DATE,b.PARTY_NAME,b.VEHICLE_NO,c.bill_no,c.BILL_DATE,c.PARTY_NAME,c.VEHICLE_NO
    ACCORDING TO THIS CODE sum of these column SUM(a.AMOUNT),SUM(b.LABOUR_AMT),SUM(c.AMOUNT) are not correct and there are one more problem if BILL_NO is not in LAB_WORK_DTL JOB_CARD_DETAILS these table then result shows NO DATA FOUND but BILL_NO is avalable in
    TRANSACTION_DETAILS this table.
    How can i generate this report .
    Thanks
    Manoj Kaushik

    1-
    CREATE TABLE  "TRANSACTION_DETAILS"
    (     "S_NO" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
         "VEHICLE_NO" VARCHAR2(20),
         "ITEM_NAME" VARCHAR2(500),
         "DESCRIPTION" VARCHAR2(4000),
         "QTY" NUMBER,
         "RATE" NUMBER,
         "AMOUNT" NUMBER,
          CONSTRAINT "TRANSACTION_DETAILS_CON" PRIMARY KEY ("S_NO") ENABLE
    2-
    CREATE TABLE  "LAB_WORK_DTL"
    (     "ID" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
    "VEHICLE_NO" VARCHAR2(20),
         "WORK_DETAIL" VARCHAR2(4000),
         "LABOUR_AMT" NUMBER,      
          CONSTRAINT "LAB_WORK_DTL_PK" PRIMARY KEY ("ID") ENABLE
    3-
    CREATE TABLE  "JOB_CARD_DETAILS"
    (     "ID2" NUMBER,
         "BILL_NO" NUMBER,
         "BILL_DATE" DATE,
         "PARTY_NAME" VARCHAR2(1000),
         "VEHICLE_NO" VARCHAR2(20),
         "AMOUNT" NUMBER,
          CONSTRAINT "JOB_CARD_DETAILS_CON" PRIMARY KEY ("ID2") ENABLE
    /Can you define the relation between these three tables. I see in your sql you are joining the three table with the column PARTY_NAME. Is that the proper joining condition? Can you explain that.
    And also when you say this
    ACCORDING TO THIS CODE sum of these column SUM(a.AMOUNT),SUM(b.LABOUR_AMT),SUM(c.AMOUNT) are not correct What exactly do you mean. What is not correct? Can you show some sample data.
    And also it would be of great help to all the people here if you format your SQL and use {noformat}{noformat} tag to preserve the format of your code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Please tell me the  Three table INNER JOIN Sql statement

    Hi experts,
      I got requirement like by using INNER JOIN i have to write the code in MY program i.e using 3 tables VBAK VBAP and VBUK.And the common field is VBELN .SO please give the  INNER JOIN SQL statement for above three tables...
    vbak-vbeln,erdat
    vbap-vbeln,posnr
    vbuk-vbeln,RFSTK
    Thanks in Advance

    hi guglani  please see my total code b.caus DATA is not extracting...once see the code  correct error.
    DATA:V_VBELN TYPE VBAK-VBELN.      "VBAK,VBAP AND VBUK
    SELECT-OPTIONS SORDER FOR V_VBELN.
    TYPES:BEGIN OF T_VBAK,
         VBELN TYPE VBELN_VA,
         ERDAT TYPE ERDAT,
      END OF T_VBAK.
    TYPES:BEGIN OF T_VBAP,
           VBELN TYPE VBELN_VA,
            POSNR TYPE POSNR_VA,
      END OF T_VBAP.
    TYPES:BEGIN OF T_VBUK,
        VBELN TYPE VBELN,
      RFSTK TYPE RFSTK,
      END OF T_VBUK.
    TYPES:BEGIN OF FS,
       VBELN TYPE VBELN_VA,
         ERDAT TYPE ERDAT,
    POSNR TYPE POSNR_VA,
      RFSTK TYPE RFSTK,
      END OF FS.
    DATA:WA1 TYPE T_VBAK,
         WA2 TYPE T_VBAP,
         WA3 TYPE T_VBUK,
         WA TYPE FS.
    DATA:ITAB1 TYPE TABLE OF T_VBAK,
          ITAB2 TYPE TABLE OF T_VBAP,
          ITAB3 TYPE TABLE OF T_VBUK,
          ITAB TYPE TABLE OF FS.
    select a~vbeln a~erdat b~posnr c~rfstk
           from vbak as a inner join vbAP as b on a~vbeln = b~vbeln
                          inner join vbuk as c on a~vbeln = c~vbeln
    into table itab
    where A~vbeln eq SORDER.
    IF NOT ITAB IS INITIAL.
      SORT ITAB BY VBELN.
    ENDIF.
    LOOP AT ITAB INTO WA.
       WRITE:/ WA-VBELN,WA-ERDAT,WA-rfstk.
       ENDLOOP.
       CLEAR WA.
       REFRESH ITAB.

  • Joining three tables

    I have to join three tables but i m getting error as given below:
    Error i m getting-
    Syntax error(missing operator) in query expression 'invoice.INVOICE_NO=inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO=inv_ent_main.INVOICE_N'.
    My Query is-
    "select inv_ent_main.EXPORTER,inv_ent_main.INVOICE_NO,inv_ent_main.INVOICE_DATE,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_AMOUNT,inv_ent_main.BALE_COUNT,inv_ent_main.TOTAL_PIECES,inv_ent_main.TOTAL_AREA,invoice.ORDER_NO,invoice.OTHER_REF,invoice.CONSIGN1,invoice.CONSIGN2,invoice.CONSIGN3,invoice.CONSIGN4,invoice.CONSIGN5,invoice.DLV_TERMS,invoice.PAYMENT_TERMS,invoice.PRE_CARRIAGE,invoice.PR_CARRIER,invoice.DESTINATION,invoice.COUNTRY_DESTINATION,invoice.VESS_FLIGHT,invoice.PORT_LOAD,invoice.PORT_DSCH,invoice.MARK1,invoice.MARK2,invoice.CURRENCY,invoice.GOODS_DESCRIPTION,invoice.CFB,invoice.GROSS_WEIGHT,invoice.NET_WEIGHT,invoice.WOOL,invoice.COTTON
    from inv_ent_main INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO";
    MCA,LUCKNOW.

    The last character in the error message has missing "O" when compare to the actual query you have posted. Please rerun it an verify or you can try the below query. You need to post DDL for all the 3 tables so that we can test.
    select
    inv_ent_main.EXPORTER,
    inv_ent_main.INVOICE_NO,
    inv_ent_main.INVOICE_DATE,
    inv_ent_main.BALE_COUNT,
    inv_ent_main.TOTAL_AMOUNT,
    inv_ent_main.BALE_COUNT,
    inv_ent_main.TOTAL_PIECES,
    inv_ent_main.TOTAL_AREA,
    invoice.ORDER_NO,
    invoice.OTHER_REF,
    invoice.CONSIGN1,
    invoice.CONSIGN2,
    invoice.CONSIGN3,
    invoice.CONSIGN4,
    invoice.CONSIGN5,
    invoice.DLV_TERMS,
    invoice.PAYMENT_TERMS,
    invoice.PRE_CARRIAGE,
    invoice.PR_CARRIER,
    invoice.DESTINATION,
    invoice.COUNTRY_DESTINATION,
    invoice.VESS_FLIGHT,
    invoice.PORT_LOAD,
    invoice.PORT_DSCH,
    invoice.MARK1,
    invoice.MARK2,
    invoice.CURRENCY,
    invoice.GOODS_DESCRIPTION,
    invoice.CFB,
    invoice.GROSS_WEIGHT,
    invoice.NET_WEIGHT,
    invoice.WOOL,
    invoice.COTTON from inv_ent_main
    INNER JOIN invoice ON invoice.INVOICE_NO = inv_ent_main.INVOICE_NO
    INNER JOIN invrate ON invrate.INVOICE_NO = inv_ent_main.INVOICE_NO
    Regards, RSingh

  • Joining Three Tables with multiple record

    Dear All
    we need some help. We have Three Tables in sqlserver2012
    Master Table
    OrderID       PackageID      CustomerName
    1                          1               Abc
    2                          2                Bcd
    3                          1                xyz
    Child1 Table
    OrderID          ControlName
    1                   Row1COlumn1             (It Means Pant in Red Color is selected by user(relation with Child2 Table))
    1                   Row3Column1             (It Means Gown in Blue Color is selected by user(relation with Child2 Table))
    1                   Row4Column3             (It Means T Shirt in White Color is selected by user(relation with Child2 Table))
    2                    Row1Column2            (It Means Tie in Green Color is selected by user(relation with Child2 Table))
    2                   Row3Column1            (It Means Bow in Red Color is selected by user(relation with Child2 Table))
    Child2 Table
    PackageID      Product      Color1     Color2    Color3
    1                       Pant        Red          Green     Blue    
    1                       Shirt        Blue      Pink    Purple
    1                       Gown         Blue      Black    Yellow
    1                       T Shirt     Red          Green     White
    2                       Tie         Red          Green     White
    2                       Socks       Red          Green     White
    2                       Bow         Red          Green     White
    We want to have result like
    OrderID    PackageID      CustomerName   Pant    Gown  T Shirt     Tie         Bow  
    1                     1                 ABC               Red     Blue    White      x    
          x
                                                                   Blue
    2                      2                 Bcd                 x         x          x
           Green      Red
    I have tried 
    ;with mycte as (
    select  ms.OrderID,ms.PackageID
    ,ms.CustomerName
    , Replace(stuff([ControlName], charindex('Column',ControlName),len(ControlName),''),'Row','')  rowNum 
    ,Replace(stuff([ControlName], 1, charindex('Column',ControlName)-1 ,''),'Column','') columnNum 
    From  child1 c inner join MasterTable ms on c.Orderid=ms.orderid)
    ,mycte1 as (
    select *, row_number() Over(Partition By PackageID Order By Child2ID) rn from child2
    ,mycte2 as (
    Select m.OrderID,m.PackageID, m.CustomerName, m.ColumnNum,  m1.Product 
    --,m1.Color1 , m1.Color2, m1.Color3 
    , Case WHEN ColumnNum= 1 Then Color1 
     WHEN ColumnNum= 1 Then Color1 
      WHEN ColumnNum= 2 Then Color2 
       WHEN ColumnNum= 3 Then Color3 End Colors  
    from mycte m 
    join mycte1 m1 on m.rowNum=m1.rn and m.PackageID=m1.PackageID)
    Select OrderID,PackageID,CustomerName, ISNULL(Max(Case WHen Product='Pant' Then Colors END),'X') as 'Pant'
    , ISNULL(Max(Case WHen Product='Gown' Then Colors END),'X') as 'Gown'
    , ISNULL(Max(Case WHen Product='T Shirt' Then Colors END),'X') as 'T Shirt'
    , ISNULL(Max(Case WHen Product='Tie' Then Colors END),'X') as 'Tie'
    , ISNULL(Max(Case WHen Product='Bow' Then Colors END),'X') as 'Bow'
    FROM mycte2
     Group by OrderID,PackageID, CustomerName
    it works if we have a product in one color only. like if we have pant in red and blue then its showing just first record
    Thanks and Best Regards Umair

    Are you really storing textual values like "Row3Column1" or "Row4Column3"???
    Your model is a mess. Redesign it.. btw, these kind of models are quite complex.
    USE tempdb;
    GO
    CREATE TABLE dbo.Colors
    ColorID INT NOT NULL ,
    ColorName NVARCHAR(255) NOT NULL ,
    CONSTRAINT PK_Colors PRIMARY KEY ( ColorID )
    CREATE TABLE dbo.Products
    ProductID INT NOT NULL ,
    ProductName NVARCHAR(255) NOT NULL ,
    CONSTRAINT PK_Products PRIMARY KEY ( ProductID ) ,
    CONSTRAINT UQ_Products_ProductName UNIQUE ( ProductName )
    CREATE TABLE dbo.Packages
    PackageID INT NOT NULL ,
    CONSTRAINT PK_Packages PRIMARY KEY ( PackageID )
    CREATE TABLE dbo.PackageDetails
    ColorID INT NOT NULL ,
    PackageID INT NOT NULL ,
    ProductID INT NOT NULL ,
    CONSTRAINT PK_PackageDetails PRIMARY KEY ( ColorID, PackageID, ProductID ) ,
    CONSTRAINT FK_PackageDetails_ColorID FOREIGN KEY ( ColorID ) REFERENCES dbo.Colors ( ColorID ) ,
    CONSTRAINT FK_PackageDetails_PackageID FOREIGN KEY ( PackageID ) REFERENCES dbo.Packages ( PackageID ) ,
    CONSTRAINT FK_PackageDetails_ProductID FOREIGN KEY ( ProductID ) REFERENCES dbo.Products ( ProductID )
    CREATE TABLE dbo.Orders
    OrderID INT NOT NULL ,
    CustomerID INT NOT NULL ,
    PackageID INT NOT NULL ,
    CONSTRAINT PK_Orders PRIMARY KEY ( OrderID ) ,
    CONSTRAINT UQ_Orders_CustomerID UNIQUE ( OrderID, PackageID ) ,
    CONSTRAINT FK_Orders_PackageID FOREIGN KEY ( PackageID ) REFERENCES dbo.Packages ( PackageID )
    CREATE TABLE dbo.OrderDetails
    ColorID INT NOT NULL ,
    OrderID INT NOT NULL ,
    PackageID INT NOT NULL ,
    ProductID INT NOT NULL ,
    CONSTRAINT FK_OrderDetails_Orders FOREIGN KEY ( OrderID, PackageID ) REFERENCES dbo.Orders ( OrderID, PackageID ) ,
    CONSTRAINT FK_OrderDetails_PackageDetails FOREIGN KEY ( ColorID, PackageID, ProductID ) REFERENCES dbo.PackageDetails ( ColorID, PackageID, ProductID )
    GO
    INSERT INTO dbo.Colors
    ( ColorID, ColorName )
    VALUES ( 1, 'Red' ),
    ( 2, 'Green' ),
    ( 3, 'Blue' ),
    ( 4, 'Pink' ),
    ( 5, 'Purple' ),
    ( 6, 'Black' ),
    ( 7, 'Yellow' ),
    ( 8, 'White' );
    INSERT INTO dbo.Products
    ( ProductID, ProductName )
    VALUES ( 1, 'Pant' ) ,
    ( 2, 'Shirt' ) ,
    ( 3, 'Gown' ) ,
    ( 4, 'T Shirt' ) ,
    ( 5, 'Tie' ) ,
    ( 6, 'Socks' ) ,
    ( 7, 'Bow' );
    INSERT INTO dbo.Packages
    ( PackageID )
    VALUES ( 1 ),
    ( 2 );
    INSERT INTO dbo.PackageDetails
    ( PackageID, ProductID, ColorID )
    VALUES ( 1, 1, 1 ),
    ( 1, 2, 3 ),
    ( 1, 3, 3 ),
    ( 1, 4, 1 ),
    ( 2, 5, 1 ),
    ( 2, 6, 1 ),
    ( 2, 7, 1 ),
    ( 1, 1, 2 ),
    ( 1, 2, 4 ),
    ( 1, 3, 6 ),
    ( 1, 4, 2 ),
    ( 2, 5, 2 ),
    ( 2, 6, 2 ),
    ( 2, 7, 2 ),
    ( 1, 1, 3 ),
    ( 1, 2, 5 ),
    ( 1, 3, 7 ),
    ( 1, 4, 8 ),
    ( 2, 5, 8 ),
    ( 2, 6, 8 ),
    ( 2, 7, 8 );
    INSERT INTO dbo.Orders
    ( OrderID, PackageID, CustomerID )
    VALUES ( 1, 1, 1 ),
    ( 2, 2, 2 ),
    ( 3, 1, 3 );
    INSERT INTO dbo.OrderDetails
    ( ColorID, OrderID, PackageID, ProductID )
    VALUES ( 1, 1, 1, 1 ),
    ( 3, 1, 1, 3 ),
    ( 8, 1, 1, 4 ),
    ( 2, 2, 2, 5 ),
    ( 1, 2, 2, 7 );
    GO
    SELECT *
    FROM dbo.Orders O
    INNER JOIN dbo.OrderDetails OD ON OD.OrderID = O.OrderID
    INNER JOIN dbo.Products P ON P.ProductID = OD.ProductID
    INNER JOIN dbo.Colors C ON C.ColorID = OD.ColorID;
    GO
    DROP TABLE dbo.OrderDetails;
    DROP TABLE dbo.Orders;
    DROP TABLE dbo.PackageDetails;
    DROP TABLE dbo.Packages;
    DROP TABLE dbo.Products;
    DROP TABLE dbo.Colors;
    GO

  • Code to Join three tables.

    Hi All,
    I am a fresher to this ABAP.
    I have an task to join three tables which doesn't take much effort. But the problem is: the tables have same columns, (name, age and city) in all the three tables.
    The layout is as shown below:
    Table 1  ( T1 )            Table 2  ( T2 )          Table 3 ( T3 )
      name | age | city      name | age | city        name | age | city    -
    Anju   21     HDD      Anju   20     BGH       Anju    21    SFF
    Julie   23     JUH       Julie   24     JUH        Julie   20     JUH
    Now, there should be a selection screen. If I enter a value for this varaible as "Anju", The output should be like:
    Col       T1        T2      T3
    Name    Anju     Anju    Anju
    Age       21        20       21
    City       HDD    BGH    SFF
    I am unable to appraoch how to solve this issue. Any pointers would be of great help.
    Thanks in advance,
    Anjum.
    Edited by: nasarat anjum on Apr 23, 2008 8:43 AM

    Hi,
    U can take three internal tables for each of ur tables T1,T2,T3. Fetch the respective table data into ur internal tables.
    Then write,
    loop at itab1.
    read table itba2 with key name eq itab1-name.
    read table itab3 with key name eq itab1-name.
    write : / name under <name heading>,
                itab1-name under <T1 heading>,
                itab2-name under <T2 heading>,
                itab3-name under <T3 heading>.
    write : / age under <age heading>,
                itab1-age under <T1 heading>,
                itab2-age under <T2 heading>,
                itab3-age under <T3 heading>.
    write : / city under <city heading>,
                itab1-city under <T1 heading>,
                itab2-city under <T2 heading>,
                itab3-city under <T3 heading>.
    <removed by moderator>
    Thanks
    Edited by: Mike Pokraka on Aug 6, 2008 8:30 AM

  • How to join three tables?

    I have used this query to join three tables but it displays an error : field vbak-vbeln is unknown.
    please help me out..
    SELECT vbak-vbeln vbak-bstnk vbap-matnr vbap-zmeng makt-maktx
    INTO CORRESPONDING FIELDs OF TABLE itab FROM vbak
    inner JOIN vbap ON vbak-vbeln eq vbap-vbeln
    inner JOIN makt ON vbap-matnr eq makt-matnr
    WHERE vbak-bstnk = s_bstnk.

    Hi mohan kumar ,
    just follow the Syntax
    SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON
    TABLE1FLD1 = TABLE2FLD1 INNER JOIN TABLE3 ON TABLE2FLD2 = TABLE3FLD2 INNER JOIN TABL4 ON  TABLE3FLD3 = TABLE4FLD3
    WHERE FLD1 = 'AA'
    Hope this may be helpful.
    Please reward points if found ok.
    Thanks and regards,
    Rajeshwar.

  • SQL Join Three Tables DW MX2004 ASP

    I'm trying to display records using three tables joined as
    shown in the SQL code below. I'm getting "no data" message when I
    test the result page from the search form. I'm using the advanced
    Dreamweaver form to enter the SQL commands. I have never used this
    feature of Dreamweaver before and I'm not sure if the code below
    follows the way DW MX will understand what I'm trying to do. Below
    is the code based on Standard SQL....not sure if DW compatible...
    This is what I typed in the SQL box:
    SELECT
    ResourceSkillMapping.resourceSkillMapID,ResourceSkillMapping.skillID,
    ResourceSkillMapping.competenceLevel,skill.skillname,resource.resourceName,resource.resour ceLoginId
    FROM ResourceSkillMapping INNER JOIN Skill ON
    ResourceSkillMapping.skillID = Skill.skillID
    INNER JOIN Resource ON
    ResourceSkillMapping.resourceSkillMapID =
    Resource.resourceSkillMapID
    WHERE (Skill.skillName = '%Skill_asp%') AND
    (Resource.resourceLoginID = '%Agent_asp%')
    AND (Resource.active = 1)
    These is typed in the variables box:
    Variable Default Runtime
    Skill_asp 1 Request.QueryString("skillname")
    Agent_asp 1 Request.QueryString("resourceLoginID")
    I'm using asp and the "Get" url parameters in the search form
    calling the result recordset in DW. I'm connecting to a SQL 2000
    server. Is this notation DW correct? Am I joining the tables
    correctly. The tables are ResourceSkillMapping, Skill and Resource.
    All I need is to be able to search by ResourceLoginID and by
    skillName on all active records (active=1). The plan is to be able
    to click on a result record and go to a detail page to update the
    "CompetencyLevel" field in the resourceSkillMapping table using the
    update behavior in DW.
    Please help as this project is due this Tue and have been
    trying every posibility I could think so far....I have read all the
    DW help facilities many pages on this and still keep getting the
    "no data" message
    Thank you,
    Carlos
    [email protected]

    >> WHERE (Skill.skillName = '%Skill_asp%') AND
    (Resource.resourceLoginID =
    >>'%Agent_asp%')
    I would say that this is where your problem is. Change it to:
    WHERE (Skill.skillName LIKE '%Skill_asp%') AND
    (Resource.resourceLoginID
    LIKE
    '%Agent_asp%')
    and your query should work, unless of course you are actually
    searching for
    2 strings that read %Skill_asp% and %Agent_asp% exactly.
    Pat.
    "ITCoreTeam" <[email protected]> wrote in
    message
    news:[email protected]...
    > I'm trying to display records using three tables joined
    as shown in the
    > SQL
    > code below. I'm getting "no data" message when I test
    the result page from
    > the
    > search form. I'm using the advanced Dreamweaver form to
    enter the SQL
    > commands.
    > I have never used this feature of Dreamweaver before and
    I'm not sure if
    > the
    > code below follows the way DW MX will understand what
    I'm trying to do.
    > Below
    > is the code based on Standard SQL....not sure if DW
    compatible...
    > This is what I typed in the SQL box:
    >
    > SELECT
    >
    ResourceSkillMapping.resourceSkillMapID,ResourceSkillMapping.skillID,
    >
    >
    ResourceSkillMapping.competenceLevel,skill.skillname,resource.resourceName,resou
    > rce.resourceLoginId
    > FROM ResourceSkillMapping INNER JOIN Skill ON
    ResourceSkillMapping.skillID
    > =
    > Skill.skillID
    > INNER JOIN Resource ON
    ResourceSkillMapping.resourceSkillMapID =
    > Resource.resourceSkillMapID
    > WHERE (Skill.skillName = '%Skill_asp%') AND
    (Resource.resourceLoginID =
    > '%Agent_asp%')
    > AND (Resource.active = 1)
    >
    > These is typed in the variables box:
    > Variable Default Runtime
    > Skill_asp 1 Request.QueryString("skillname")
    > Agent_asp 1 Request.QueryString("resourceLoginID")
    >
    > I'm using asp and the "Get" url parameters in the search
    form calling the
    > result recordset in DW. I'm connecting to a SQL 2000
    server. Is this
    > notation
    > DW correct? Am I joining the tables correctly. The
    tables are
    > ResourceSkillMapping, Skill and Resource. All I need is
    to be able to
    > search by
    > ResourceLoginID and by skillName on all active records
    (active=1). The
    > plan is
    > to be able to click on a result record and go to a
    detail page to update
    > the
    > "CompetencyLevel" field in the resourceSkillMapping
    table using the update
    > behavior in DW.
    > Please help as this project is due this Tue and have
    been trying every
    > posibility I could think so far....I have read all the
    DW help facilities
    > many
    > pages on this and still keep getting the "no data"
    message
    > Thank you,
    > Carlos
    > [email protected]
    >

Maybe you are looking for

  • How can I share notes from iPhone to MaCbook

    I can't share my notes from my iPhone to my MacBook. How do you do that?

  • Background image and CSS?

    I am building a page to resemble our companies website.  Right now my page is linking to some external images.  I think this maybe affecting how my background looks.  If you look at this link: http://www.ournewspace.com/melanieshefchik You will see a

  • A1347

    How do I install audio drivers for windows 7 64bit with a mac mini a1347?

  • Attachment display

    Hi,              As in FB03 transaction we have option of seeing attachment document attached on double click.. How do we display the Document on double click in my custom program.. The Attached Document information ie doc id is available in table to

  • TS1702 Why are my apps updates and apps remaining in the "waiting" and "pause" state?

    I get update notices for my apps but when I click to update my apps remain in the "waiting" and "Pause" state. I have tried powering down my phone and restarting it to see if that will resovle the problem but it's not correcting the problem. I have d