Qurey for pulling out data from three tables... Pls help me out.

Hi..
I have three tables linkdetails, wingdetails and vendordetails. A link is connecting two wings... and link is provided by a vendor.. So the fields of linkdetails are---- linkdetails: linkid , linkname, vendorid,wing_a_id,wing_b_id
vendordetails: vendorid, vendorname, contactnumber
wingdetails: wingid,wingname,city
So i want a query that retrieves all the fields from linkdetails, vendorname from vendordetails wingname corresponding to wing_a_id, wingname corresponding to wing_b_id from wingdetails for a particular linkid..
Thanks in advance

maybe something like:
  select ld.*,
         vd.vendorname,
         wda.wingid   wingid_a,
         wda.wingname wingname_a,
         wdb.wingid   wingid_b,
         wdb.wingname wingname_b
    from linkdetails   ld,
         vendordetails vd,
         wingdetails   wda,
         wingdetails   wdb
   where ld.vendor_id = vd.vendorid
     and ld.wing_a_id = wda.wingid
     and ld.wing_b_id = wdb.wingid
     and ld.linkid    = &linkid;

Similar Messages

  • Gui_download for transferring the data from internal table to excel sheet.

    hi all,
    i am using gui_download for transferring the data from internal table to excel sheet.
    I have a internal table with 3 columns col1,col2,col3 and I am getting the file at the specified path,but my problem is that,in the excel sheet(path specified) all the 3 columns values are printed in one column.Please help me.
    Thanks in advance.

    Hi Venkata,
    plz use FM 'SAP_CONVERT_TO_XLS_FORMAT' :
      call function 'SAP_CONVERT_TO_XLS_FORMAT'
        exporting
    *   I_FIELD_SEPERATOR          =
    *   I_LINE_HEADER              =
          i_filename                 = p_file
    *   I_APPL_KEEP                = ' '
        tables
          i_tab_sap_data             = t_mbew
    * CHANGING
    *   I_TAB_CONVERTED_DATA       =
    * EXCEPTIONS
    *   CONVERSION_FAILED          = 1
    *   OTHERS                     = 2
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    Hope this helps,
    Erwan

  • Selecting data from three tables

    Hi Every one...
    I have three tables, Tbl_FlData, Tbl_Flsubdata,Tbl_OutDirection_Dtl, in these tables the common columns are OUTNO, OUTYEAR. When I am trying to pull data from two tables Tbl_Fldata, Tbl_OutDirection_Dtl by using below query I am getting exact output what i want.
    SELECT Tbl_FLData.OUTNO, Tbl_FLData.OUTHDATE,Tbl_OutDirection_Dtl.OTSERNO FROM Tbl_FLData INNER JOIN Tbl_OutDirection_Dtl ON Tbl_FLData.OUTYEAR = Tbl_OutDirection_Dtl.OUTYEAR AND Tbl_FLData.OUTNO = Tbl_OutDirection_Dtl.OUTNO.
    But the problem is, when I am trying to pull a column from Tbl_FlSubdata.Remarks the out put is coming but the records are duplicating.
    The fields of the tables are
    Tbl_FlData: OUTNO, OUTYEAR, OUTHDATE, SUBJECT,USERDEPTCODE, FDEPTCODE, SENDHDATE, REPLYINDAYS, EXPECTEDHDATE, UD_UID
    Tbl_FLSUBDATA: OUTNO, OUTYEAR, OTSSERNO, SEQNO, EMPCODE, SEQHDATE, REMARKS, UD_UID
    Tbl_OutDirectionDtl : OUTNO, OUTYEAR, OTSERNO, DI_Code, REPLYHDATA, INNO, INHDATE, IN_UD_UID, IN_REMARKS.
    Please help me in this issue.

    Hi,
    Try something like this.
    SELECT distinct Tbl_FLData.OUTNO,
    Tbl_FLData.OUTHDATE,
    Tbl_FLSUBDATA.OTSSERNO
    Tbl_OutDirection_Dtl.OTSERNO
    FROM Tbl_FLData, Tbl_FLSUBDATA, Tbl_OutDirection_Dtl
    where Tbl_FLSUBDATA.OUTNO = Tbl_FLData.OUTNO(+)
    and Tbl_OutDirection_Dtl.OUTNO = Tbl_FLData.OUTNO(+)
    order by Tbl_FLData.OUTNO;
    considering Tbl_FLData as the master table. If there are any other unique fields like "out_no" include it a way as above after "where" with a (+) join and see if you still get duplicates.

  • How can i Delete the data from three tables at a time  using same key.

    I am New to Oracle ADF, I have a Requirement Like these, I have three tables like Employee,Salaries,Teams all of these are having one common EmpNo as common attribute, I have Search form these will return the all the employees related to that search query, when i click on Delete button the particular employe Data should delete from all the three tables based on the EmpNo.
    Any Help is appreciable..

    1) The easiest way is to mark the foreign key constraints from SALARIES to EMPLOYEES and from TEAMS to EMPLOYEES as ON DELETE CASCADE. The DB server will then delete the necessary rows whenever you delete an employee row.
    2) Another way is to implement a Before-Delete-Row DB trigger on the EMPLOYEES table where you can delete the related rows in the other tables (have in mind, that if you have foreign keys you may get a Mutating Table Exception, so this approach might be not very good).
    3) An ADF way is to implement a custom EntityImpl class for the Employee entity and to override the remove() method where you can lookup the related TeamMember and Salary entities (through EntityAssoc accessors) and invoke their remove() methods too.
    4) Another ADF way is to implement a custom EntityImpl class for the Employee entity and to override the doDML() method where you can delete the necessary rows in SALARIES and TEAMS tables through JDBC calls whenever a DELETE operation is being performed on the underlying Employee entity.
    Dimitar

  • Fetching data from three tables.

    Hi All,
    I am having three tables company(com_id(PK),com_name),
    contact(contact_id(PK),com_id(FK),first_name,email),
    location(loc_id(PK),com_id(FK),country).
    I need a query to retrieve the first name,email,com_name and country.
    I used:
    select contact.first_name,contact.email,company.com_name,m.country from contact
    LEFT JOIN location m ON contact.com_id=m.com_id
    LEFT JOIN company c ON contact.com_id=c.com_id
    but its returning duplicate rows.
    I am new to this .Please tell me how to solve this problem.
    thanks,

    Jeeth wrote:
    Hi
    Thanks to all for the reply..
    I am using Oracle 10g
    Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionThat says you're uising Oracle 11 (11.2.0.1.0 to be precise), not 10.
    ... And the LOCATION Table containing:
    COM_ID     ADDRESS_ID COUNTRY
    28     1265     United States
    28     1266     United States
    381     381     United States
    610     1873     United States
    864     1586     United States
    869     870     United States
    2414     2662     United StatesPost CREATE TABLE and INSERT statments for your sample data.
    It helps if you explain what the data means. For example, this problem seems to hinge on location.com_id not being unique. What does each row, and each column, in the location table represent? What does each row in the output represent?
    Tried the Query:
    select d.first_name, d.email ,c.com_name , m.country from company c,contact d,location m
    where c.com_id=d.com_id and c.com_id=m.com_id
    I got the result: The second row is repeating:
    Alexander     [email protected]     JPMorgan Chase &amp; Co. (KEY ACCOUNT)     United States
    Alexander     [email protected]     ADP, Inc.      United States
    Alexander     [email protected]     ADP, Inc.      United States
    Alfred     [email protected]     Perficient Inc.     United States
    Allan     [email protected]     Progressive Insurance     United States
    Linda      [email protected]     Principal Financial Group, Inc.     United States
    Alycia     [email protected]     Emerson Electric Co. (KEY ACCOUNT)     United States
    Want output like:
    Alexander     [email protected]     JPMorgan Chase &amp; Co. (KEY ACCOUNT)     United States
    Alexander     [email protected]     ADP, Inc.      United States
    Alfred     [email protected]     Perficient Inc.     United States
    Allan     [email protected]     Progressive Insurance     United States
    Linda      [email protected]     Principal Financial Group, Inc.     United States
    Alycia     [email protected]     Emerson Electric Co. (KEY ACCOUNT)     United States
    Why do you want that ouptut, and not the output that you're originally getting?
    What output would you want if the part you were displaying were different on each row. For example, if we add a row like this to the sample data:
    COM_ID     ADDRESS_ID     COUNTRY
    2414     2663          MexicoThee are many different reasons why you could want the output you do. Each one has a different solution, that would produce different results with different data. You need to explain what you want to do, then someone can help you find a way to code it.
    The simplest way is to say SELECT DISTINCT . That happens to get the right results with the given sample data.

  • Need help in writing a select query to pull required data from 3 tables.

    Hi,
    I have three tables EmpIDs,EmpRoles and LatestRoles. I need to write a select Query to get roles of all employees present in EmpIDs table by referring EmpRoles and LatestRoles.
    The condition is first look into table EmpRoles and if it has more than one entry for a particular Employee ID than only need to get the Role from LatestRoles other wise consider
    the role from EmpRoles .
    Sample Script:
    Create Table #EmpIDs
    (EmplID int )
    Create Table #EmpRoles
    (EMPID int,Designation varchar(50))
    Create Table #LatestRoles
    EmpID int,
    Designation varchar(50)
    Insert into #EmpIDs values (1),(2),(3)
    Insert into #EmpRoles values (1,'Role1'),(2,'Role1'),(2,'Role2'),(3,'Role1')
    Insert into #LatestRoles values (2,'Role2')
    Employee ID 2 is having two roles defined in EmpRoles so for EmpID 2 need to fetch Role from LatestRoles table and for
    remaining ID's need to fetch from EmpRoles .
    My Final Output of select query should be like below.
    EmpID Role
    1 Role1
    2 Role2
    3 Role1
    Please help.
    Mohan

    Mohan,
    Can you check if this answers your requirement:
    Create Table #EmpIDs
    (EmplID int )
    Create Table #EmpRoles
    (EMPID int,Designation varchar(50))
    Create Table #LatestRoles
    EmpID int,
    Designation varchar(50)
    Insert into #EmpIDs values (1)
    Insert into #EmpIDs values (2)
    Insert into #EmpIDs values (3)
    Insert into #EmpRoles values (1,'Role1')
    Insert into #EmpRoles values (2,'Role2')
    Insert into #EmpRoles values (2,'Role1')
    Insert into #EmpRoles values (3,'Role1')
    Insert into #LatestRoles values (2,'Role2')
    --Method 1
    select e.EmplID,MIN(ISNULL(l.Designation,r.Designation)) as Designation
    from #empids e
    left join #emproles r on e.emplID=r.EmpID
    left join #latestRoles l on e.emplID=l.EmpID
    group by e.EmplID
    --Method 2
    ;with cte
    as
    select distinct e.EmplID,r.Designation,count(*) over(partition by e.emplID) cnt
    from #empids e
    left join #emproles r on e.emplID=r.EmpID
    select emplID,Designation
    from cte
    where cnt=1
    UNION ALL
    select a.EmplID,l.Designation
    from
    (select distinct EmplID from cte where cnt>1) a
    join #Latestroles l on a.EmplID=l.EmpID
    order by emplID
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Performance tuning for extraction of data from MSEG table

    Hello experts,
    I m trying to extract data via select query from MSEG table based on non-primary keys, which affects my performance.
    Below is my select query  :
    SELECT SINGLE menge
    FROM mseg
    INTO w_rejqty
    WHERE ebeln = it_mseg-ebeln AND
          ebelp = it_mseg-ebelp AND
          bwart = '122'.   
    Kindly suggest some alternative way for it apart from creating secondary index on table MSEG which would be my last option because already four secondary index are created in my present situation and also is it advisable to create fifth secondary index for my problem?? Would it affect my database performance?
    Thanks in advance
    Raj

    Hi Raj,
    is that possible to use this query below ? You might ask to Functional whether is possible or not.
    SELECT SINGLE belnr gjahr buzei INTO w_ekbe FROM ekbe
        WHERE ebeln = it_mseg-ebeln
        AND     ebelp = it_mseg-ebelp
    SELECT SINGLE menge FROM mseg INTO w_rejqty
       WHERE mblnr EQ w_ekbe-belnr
       AND   mjahr EQ w_ekbe-gjahr
       AND   zeile EQ w_ekbe-buzei
    Best Regards
    Fernand

  • How to get data from three tables (A,B,C) having one to many relation between A and B .and having one to many reation between b and c

    i have  three tables A,B,C.  there is one to many relation between A and B. and one to many relation existed between table b and c . how will get data from these three tables

    check if this helps:
    select * --you can always frame your column set
    from tableA a
    left join tableB b on a.aid=b.aid
    left join tableC c on c.bid=b.bid
    This is just a general query. However, we can help you a lot more, if you can post the DDL + sample data and required output.
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Getting data from three tables

    I have 3 tables
    SQL> select * from t1;
    C1
    d1
    d2
    SQL> select * from t2;
    C1 C2
    d1 g1
    d1 wf1
    d2 g2
    d2 wf2
    SQL> select * from t3;
    C2 C3
    wf1 open
    wf1 closed
    wf1 closed
    wf1 cancelled
    wf2 closed
    wf2 cancelled
    wf2 closed
    I would like to join rows from t1 and t2 for no t3.c3='open' ie the result I want is:
    C1 C2
    d2 wf2
    d2 g2
    Thanks

    Am afraid, if you look at it logically from your table structure, you can see you only have one data open. So the result you expected to get as stated is wrong.
    I believe this is the correct answer
    SQL> select a.c1, b.c2, c.c3 from t1 a, t2 b, t3 c where a.c1 = b.c1 and b.c2 = c.c2 and c.c3 = 'ope
    n' order by 1;
    C1 C2 C3
    d1 wf1 open
    Cube60

  • Error for datawindow get data from temp table with SP

    I create a SP to produce results. In this SP, results recorded in a temp table #mytemp. The final sql in this sp is like:
    select * from #mytemp
    Then I create datawindow to display data from this sp and got following error:
    Number 277 Select Error: there was a transactin active when exiting the stored procedure 'myproc'. The temporary table '#mytemp' was dropped in this transaction either explicitly or implicitly. This transaction has been aborted to prevent database corruption.
    How to resolve this problem?

    Sorry but could not reproduce the problem with the following products:
    PB 12.5.2 build 5652
    ASE client 15.7 EBF22688
    ASE server 15.7 EBF 19496
    Tested with ASE and SYC database profiles
    // Profile ASE
    SQLCA.DBMS = "ASE Adaptive Server Enterprise"
    SQLCA.Database = "repro"
    SQLCA.LogPass = <**********>
    SQLCA.ServerName = ""
    SQLCA.LogId = "sa"
    SQLCA.AutoCommit = False
    SQLCA.DBParm = ""
    // Profile SYC
    SQLCA.DBMS = "SYC Adaptive Server Enterprise"
    SQLCA.Database = "repro"
    SQLCA.LogPass = <**********>
    SQLCA.ServerName = "xxxxxxxx"
    SQLCA.LogId = "sa"
    SQLCA.AutoCommit = False
    SQLCA.DBParm = "Release='15'"
    Below is the source of my stored procedure.
    Prior to run the script, execute a data pipeline to create ASA tables (EAS Demo DB V12.5) department and employees into your ASE server
    CREATE PROCEDURE mySP
    AS
        BEGIN
           create table #employee_working (
             emp_id  int not null,
             manager_id  int null,
             emp_fname   varchar(20)    not null,
             emp_lname   varchar(20)    not null,
             dept_id int not null,
             dept_name varchar(40) not null )
          insert into #employee_working
             select employee.emp_id, employee.manager_id, employee.emp_fname, employee.emp_lname, employee.dept_id, department.dept_name
             from employee , department
             where employee.dept_id = department.dept_id
        select #employee_working.emp_id, #employee_working.manager_id, #employee_working.emp_fname, #employee_working.emp_lname,
        #employee_working.dept_id, #employee_working.dept_name
            from #employee_working
        END
    Jacob

  • Fetch the data from three tables

    hi
    i have three table HR,plan ,voidplan
    HR table
    rep_id name
    1111 shyam
    2222 kavi
    3333 snaga
    PLAN table
    id rep_id name status
    1 1111 shyam approved
    2 2222 kavi pending
    VOID PLAN table
    id rep_id name status
    1 1111 shaym approved
    i got the row which is same in two table(HR and PLAN) using the query
    select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
    so the output is
    rep_id
    1111
    now i need the solution to retrieve the rep from voidplan+plan table
    the result should be like this
    rep_id
    1111(from plan and hr)
    1111(void plan)
    please help me to solve this problem
    regards,
    vally.s

    how about UNION ALL
    select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
    union all
    select rep_id from void_plan
    this will get only the rows that join and then ALL rows from void_plan (but I suspect this isn't what you want?)
    maybe you only want rows from void_plan that are returned from the first query
    select rep_id from void_plan v
    where v.rep_id in (select rep_id from plan p,hr h where h.rep_id=p.rep_id and status='approved'
    )

  • Without ABAP progrm can we pull the data from ECC table

    Is it possible to define in Table attract XI SAP as a whole what it is, without having to configure ABAP program in R / 3 to collect all send XI?
    JOB is run on XI pull an entire table into a file folder and put it online?
    Can we usse jdbc adapter anyhow to pull the records frm SAP database tables........

    Hi,
    >>Is it possible to define in Table attract XI SAP as a whole what it is, without having to configure ABAP program in R / 3 to collect all send XI?
    Yes, but not recommended by SAP...  Remeber SAPECC or R3 is installed over a DB so you have the tables there, and you can pull data through it.. but always go for an ABAP program to do so..
    >>JOB is run on XI pull an entire table into a file folder and put it online?
    yes this can be done, with the JOB calling an abap program (through XI or any other way)
    >>Can we usse jdbc adapter anyhow to pull the records frm SAP database tables........
    Again yes, but not recommended..
    Regards
    Suraj

  • Select data from three tables

    Hi,
    Tables :PROJ-JEST-TJ30T     Target Field:TXT04
    PROJ-PSPNR--> PROJ-OBJNR =JEST-OBJNR  + JEST-INACT = «blank»
    JEST-STAT = (TJ30T-ISTAT = E* (we have to take only E*)+ TJ30T-SPRAS = EN) -->TJ30T-TXT04
    We can have some status to display here, please concatenate and separate them by a coma.
    can you give me suggestion to fill that requirement?
    Regards
    Subbu

    sth like this:
        SELECT
               P~pspnr...
                                                                                    INTO   CORRESPONDING FIELDS OF  itab
                    FROM ( proj AS p INNER JOIN jest AS J
                           ON POBJNR = JOBJNR )
                    join TJ30T as t
                          on T~ISTAT =  J-TSTAT
               WHERE T~spras = 'EN'
                 and      T~ISTAT  like 'E%'.....
    A.

  • Pull data from SQL Table and display it in mail

    I have a requirement to pull the data from SQL table and send it in email.  Currently I am sending the hard coded info in email but is it possible to pull some data from SQL Table and than format it and send it across in the same email? 
    Can you guide me with steps on this.
    Neil

    There are several ways to do this.  First is to populate a file in a data flow and then send that as an attachment in the send mail task. 
    As far as including the results in the email body this becomes a bit trickier.  To use a variable you would need to use an SSIS variable type of
    Object, this is similar to a collection in .NET.  The problem once the object is populated is that it isn't like a readable result set, but again more like an array or a collection.  There is no native method to take the object variable and
    specify .ToString() or cast its results as text.  You would need to iterate through each row and append it to another variable of type string, this could be done with a script task or ForEach container.
    Also you mentioned formatting the results.  What type of formatting were you looking for.  A limitation of the SMTP send mail task is that the message body doesn't support HTML so if you were looking at creating a table within the mail body you
    would have to use a script task or a custom component
    David Dye My Blog

  • Pull the data from ORACLE

    Hi Guru's,
    I would like to know ,How to pull the Data from Oracle tables to BW.
    tell me scratch onwards...
    regards
    sekhar ch

    Hi...
    In the admin workbench open the modeling tab and select Source Systems
    In the right pane, right-click on Source Systems and select Create…
    A dialog requires you to define the type of source system. Select “Database System”
    Enter a description for the source system
    Once you accept the definition of the source system, you have to provide the following information, save and back out:
    DBMS: ORA (Oracle)
    User Name: Your UID
    DB password: Your pwd
    Conn. Info: sql*net string
    Select “Permanent connection” if this is the case
    If everything went well, you should see the new source system. When you do a right-click and ask for the DataSource overview, the first time you execute it you will be prompted to generate the application hierarchy
    In order to test connectivity, right-click on the source system and select “Select Database Tables”
    The following screen shows up. Click on the execute button…
    any tables or views that you have access through your UID
    Select a table or view and click on “Edit DataSource”
    To test data retrieval, click on “Display table contents”
    Designate the application component, determine the type of DataSource (Text, Master data, or Transaction data) then generate the DataSource
    with regards,
    hari

Maybe you are looking for

  • How do I sort out the troubles on the console?

    Gmail - [#SAM-621717]: Trial of home intego          15/03/13 10:59 PM [#SAM-621717]: Trial of home intego 2 messages Intego Support <[email protected]> Reply-To: [email protected] To: mlkessell@**** Cc: monicakessell02@**** Hello Monica, Fri,

  • Confused about SOAP

    Hi all, As far as I know, SOAP is initially designed to be an XML based RPC protocol. But Java API for XML Messaging (JAXM), which is actually a messaging API (and not RPC), is also based on SOAP. How do they fit to each other? In a few words, what d

  • Creating Mobile Link that Isn't Visible on Desktop Browser

    I hope this makes sense. I have a mobile site with a link to my desktop site. I also want to add a link on the desktop site for mobile visitors to get back to the mobile site. But I don't want this link visible on a desktop browser... only visible on

  • Referencing cells in other documents?

    Is there a way to have a cell reference the value of a cell in another Numbers document?

  • ASCII string to Unicode

    My problem: i have to parse a file-format where special-characters are replaced by an (ASCII) escape sequence - e.g. \344 or \u2200. I get these char-sequences through a FileReader and a StreamTokenizer into a String. Since i need to draw the String,