HOW CAN I  USE MULTIPLE INNERJOINS IN A SINGLE SELECT STATEMENT?

HI,
I AM SHABEER AHMED,
I AM GETTING AN ERROR WHILE I ATTEMPT TO EXECUTE A SELECT STATEMENT WITH MULTIPLE INNER JOINS . BECOZ I WANT TO FETCH ITEM DATA, PARTNER DATA  BASED ON HEADER DATA .
THEN OF COURSE I HAVE FETCH DATA FROM VBAK VBAP VBKD SO LZ SEND ME THE SOLUTION.
BYE

Hi,
1.Just see this:
SELECT * INTO CORRESPONDING FIELD OF TABLE itab
FROM t1 INNER JOIN t2 ON t1f4 EQ t2f4
INNER JOIN t3 ON t2f5 EQ t3f5 AND
t2f6 EQ t3f6 AND
t2f7 EQ t3f7.
2.But better to use for all entries.It increases the performance.
FOR ALL ENTRIES
Tabular Conditions
The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:
SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...
<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.
The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.
You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.
Example for ALL ENTRIES
DATA: TAB_SPFLI TYPE TABLE OF SPFLI,
TAB_SFLIGHT TYPE SORTED TABLE OF SFLIGHT
WITH UNIQUE KEY TABLE LINE,
WA LIKE LINE OF TAB_SFLIGHT.
SELECT CARRID CONNID
INTO CORRESPONDING FIELDS OF TABLE TAB_SPFLI
FROM SPFLI
WHERE CITYFROM = 'NEW YORK'.
SELECT CARRID CONNID FLDATE
INTO CORRESPONDING FIELDS OF TABLE TAB_SFLIGHT
FROM SFLIGHT
FOR ALL ENTRIES IN TAB_SPFLI
WHERE CARRID = TAB_SPFLI-CARRID AND
CONNID = TAB_SPFLI-CONNID.
LOOP AT TAB_SFLIGHT INTO WA.
AT NEW CONNID.
WRITE: / WA-CARRID, WA-CONNID.
ENDAT.
WRITE: / WA-FLDATE.
ENDLOOP.
INNER JOINS
In a relational database, you normally need to read data simultaneously from more than one database table into an application program. You can read from more than one table in a single SELECT statement, such that the data in the tables all has to meet the same conditions, using the following join expression:
SELECT...
FROM <tab> INNER JOIN <dbtab> AS <alias> ON <cond> <options>
where <dbtab> is a single database table and <tab> is either a table or another join expression. The database tables can be specified statically or dynamically as described above. You may also use aliases. You can enclose each join expression in parentheses. The INNER addition is optional.
A join expression links each line of <tab> with the lines in <dbtab> that meet the condition <cond>. This means that there is always one or more lines from the right-hand table that is linked to each line from the left-hand table by the join. If <dbtab> does not contain any lines that meet the condition <cond>, the line from <tab> is not included in the selection.
The syntax of the <cond> condition is like that of the WHERE clause, although individual comparisons can only be linked using AND. Furthermore, each comparison must contain a column from the right-hand table <dbtab>. It does not matter on which side of the comparison it occurs. For the column names in the comparison, you can use the same names that occur in the SELECT clause, to differentiate columns from different database tables that have the same names.
The comparisons in the condition <cond> can appear in the WHERE clause instead of the ON clause, since both clauses are applied equally to the temporary table containing all of the lines resulting from the join. However, each join must contain at least one comparison in the condition <cond>.
Example for INNER JOINS
REPORT demo_select_inner_join.
DATA: BEGIN OF wa,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
bookid TYPE sbook-bookid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY carrid connid fldate bookid.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
LOOP AT itab INTO wa.
AT NEW fldate.
WRITE: / wa-carrid, wa-connid, wa-fldate.
ENDAT.
WRITE / wa-bookid.
ENDLOOP.
Regards,
Shiva Kumar(Reward if helpful).

Similar Messages

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • How Can I Use Multiple Weblogic Instances in a Single OS

    Hello Everyone,
    Actually I have to install Some different applications. Few of them need weblogic 10.3.6 and others need 10.3.4. The OS am using is Oracle  Enterprise Linux 5.
    Now I am able to install 2 separate(One of 10.3.4 and 10.3.6) instances with two different users,In two different directories.
    I have installed the weblogic 10.3.6 version with a user webadmin and installed node manager with port 5556. This is working fine.
    The main problem here is :
    In the second instance (10.3.4 ) installed with a a different user and gave the port number to NodeManager as 1600 and its not getting started. Its throwing error and also after some errors in the terminal am able to see that its reverting to port number 5556 only.
    What might be the issue?
    I have to install 2 different versions of weblogic in a single Server. But am failing with NodeManager. What Can I do to have multiple weblogic instances with multiple versions in a single server ?
    Can anyone suggest a resolution for this please ?
    Thanks in advance.

    Pl do not spam these forums with multiple posts - How Can I Use Multiple Weblogic Instances in a Single OS

  • How can we use multiple transactions by using bdc_insert.

    HI
    How can we use multiple transactions by using bdc_insert.

    Hi,
    In between the Open and Close we have to use the BDC_INSERT for the Tcodes you have to do.
    BDC_OPEN_GROUP
    BSD_INSERT
    TCODE = tcode1
    BDC_INSERT
    TCODE = tcode 2
    BDC_CLOSE_GROUP
    check the SDN for more on this.
    Regards
    Lekha

  • How can i scan multiple pages in a single file in pdf.

    How can i scan multiple pages in a single file in pdf using 1536 dnf.

    Hi @veerendrajain ,
    I see that you would like to save multiple PDF documents into one file. I would like to help you out today.
    In the HP Scan Software, select Advanced scan settings, click on the File tab and uncheck Create a separate file for each scanned image.
    Hope this helps.
    Have a nice day!
    Thank You.
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" on the right to say “Thanks” for helping!
    Gemini02
    I work on behalf of HP

  • How can we save multiple IDocs as a single Flat file in R/3 system ?

    Hi,
    How can we save Multiple Idocs as a single Flat IDoc in R/3 (Not xmlized)
    Kulwinder

    Hi,
    Check this link for Mutiple IDOCs into single File.
    /people/pooja.pandey/blog/2005/07/27/idocs-multiple-types-collection-in-bpm
    Regards,
    phani
    Reward points if Helpful:)

  • How can i use multiple row subquery in update statement

    Hai All
    I using group function in my update statement.. and i need to update more rows so i need to use multiple row
    subquery pls tell me how to use multiple row subquery in update statement
    For example
    while i am using this like this i got an error
    update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
    barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
    Pls tell me how to use with example
    Thanks & regards
    Srikkanth.M

    Hai Man
    Thanks for ur response Let me clear what i need
    First step Fetch the records as text file and stores into table T1
    and the next step is i have seperated the text using substring and stores in different columns of a table
    There are two shifts 0815 to 1645 and 1200 and 2000
    Here I rep IN and O rep OUT
    Empno date time inout
    001 01-01-10 0815 I
    002 01-01-10 0815 I
    003 01-01-10 0818 I
    001 01-01-10 1100 0
    001 01-01-10 1130 I
    002 01-01-10 1145 0
    002 01-01-10 1215 I
    004 01-01-10 1200 I
    005 01-01-10 1215 I
    004 01-01-10 1315 O
    004 01-01-10 1345 I
    001 01-01-10 1645 0
    002 01-01-10 1715 0
    003 01-01-10 1718 0
    004 01-01-10 2010 0
    005 01-01-10 2015 0
    This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
    T2 contains like this
    Empno Intime Intrin Introut Outtime Date
    001 0815 1100 1130 1645 01-01-10
    002 0815 1145 1215 1715 01-01-10
    003 0818 1718 01-01-10
    004 1200 1315 1345 2010 01-01-10
    005 1215 2015 01-01-10
    This what i am trying to do man but i have little bit problems Pls give some solution with good example
    And my coding is
    declare
         emp_code varchar2(25);
    in_time varchar2(25);
    out_time varchar2(25);
    Cursor P1 is
    Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    From temp_att
    group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
    ORDER BY enpno,pdate,ptime;
    begin
         for r2 in p1 loop
    declare
    bar_code varchar2(25);
    begin
    select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
    For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
    if r2.inout ='O' then
    update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
    end if;
    end loop;     
    exception
         when no_data_found then
         if r2.inout ='I' then
                   insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
         end if;
    end;
    end loop;
    commit;     
         end;
    Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
    and how can i use it in the update statement
    Thanks In Advance
    Srikkanth.M

  • TA23485 How can I use multiple identities in Mail?

    To be specific: How can I use one email address and different names? I used to do this with Eudora.

    MrHoffman: thank you for the answer. You answered to the question: many email addresses and different names, it seems. Please read my question once again and let me know if you have a solution.

  • How can I use multiple icloud Accounts with Fotos?

    Hello.
    Yesterday, my wife and I started using the new App "Fotos" on OSX and iOS.
    What I can't figure out, and where I would like to get some insight and help, is how we should use our icloud Accounts.
    How it is right now:
    - Wife (MacBook and iPhone)
    Has her own icloud-Account ([email protected]) for Backup (iOS) and Fotosync, Keychainsync, Bookmarks. 20GB iCloud-Account (18GB free).
    - Husband (MacBook, Mac Mini and iPhone and iPad)
    Has his own icloud-Account ([email protected]) for Backup (iOS) and Fotosync, Keychainsync, Bookmarks. 20GB iCloud Account (10 GB free).
    - Husband has about 400 GB of Photos from over 10 Years on Mac Mini
    How I want it to be:
    - Husband
    upgrades to at least the 500GB Account, to use for all 400GB of Photos and Backup, Keychainsync, Bookmarks.
    - Wife
    Has her own Account ([email protected]) for Keychain and Bookmark, but uses [email protected] on MacBook and iPhone for Backup an Fotosync, so that all Photos are stored in a single one family "container". All Photos in one Place without being able to forget to put them there.
    I don't see, how I can accomplish that, since only one "real" icloud account seems to be possible in iOS, so that if i put my account in her iPhone I would get the Photo and Backup I want, but she would not be able to sync her own bookmarks an keychain any more.
    Any thought on how to resolve this?
    Am I missing something?
    Thanks for your ideas,
    thomas

    Yes, you could have multiple iCloud accounts for Mail, Contacts, Calendars, Reminders, Safari, Notes, and Find My iPhone, but only one primary iCloud account for Photo Stream, Documents & Data, and Storage & Backup.

  • With Pages 5.2 how can i use multiple language types in a single document

    My Macbook Air Has the version 10.9.3
    I'm used to work with the old version of Page.
    But now I am using the new version of Pages 5.2 (1860).
    I want to know with the new version how do I use an multiple language types in a single document option.
    In the old  version of Pages I was using  Inspector -> Text -> "More" tab -> Language: British Inglese.
    In the new Pages 5.2 I do not know how to do it
    Could you help me?
    melo

    It's not possible to tag text with multiple languages in Pages 5.  Go back to Pages 4, which should still be in you iWork folder.
    For the whole doc in Pages 5, use Edit > Spellling and Grammar > Show Spelling and Grammar.

  • How can I use multiple constructor

    Hi,
    I have some problem to using multiple constructor in java. It shows some error while compiling the following program. can any one give better solution for me.......
    public class Test6{
       public Test6(){
    this(4);    /*
    C:\Test6.java:5: cannot find symbol
    symbol  : constructor Test6(int)
    location: class Test6
    this(4);
      Test6(byte var){
    System.out.println(var);
    public static void main(String[] args){
    Test6 t6 = new Test6();
    }

    A number like 4 is an integer literal. So, you are passing an int to a function that is defined to accept a byte, hence you have a type mismatch. You need to cast the integer literal to a byte before passing it to the function:
    this( (byte) 4);

  • How can we see multiple devices on a single map using find my ipad?

    We have 70 iPad/iPhone devices that we want to locate at any given time.  How can we display them on a single map?

    if they use the same appleID then you can do it at www.icloud.com

  • How can I use multiple iTunes accounts on one phone?

    I Have an iTunes account with iTunes match enabled. I've just moved in with my gf and want to be able to share music on our phones. I've enabled her computer and put my Apple ID in and I now have all her music on my phone (thanks to iTunes match) but when I try and **** her phone it ignores all my music. How can I get all my music on her phone? The only way I have managed it is to sign out of her account on the phone and sign in with my ID but that would mean all her purchases would be charged to me etc so this isn't a solution really

    Put everything on the computer to which she syncs, and sync them to her iPhone.

  • How can i use multiple languages ?

    I want to add language options on my web page.
    I duplicate a page, wanting to translate it.
    On the menu bar, the name of the new page appears.
    How can I make it unvisible ?

    This iWebFAQ.org page may be of interest to you....
    http://iwebfaq.org/site/iWeb_Multilingual_sites.html

  • How can I connect multiple clients to a single client ?

    I am currently developing an instant messaging program.I created a server and connected multiple clients to it by using thread logic.However I do not know how to connect multiple client to a single client.
    What shall I do for that?Does anybody know a good tutorial or sample program?Or shall anybody explain me what I shall do for building the Instant Messaging part of my chat program?
    Thank u in advance.

    You may use UDP multicast socket. But since you are using the UDP protocol you might risk losing the data that you send since UDP does not guarantee the safe transfer of data.
    Alternately, you might create a server that allows multiple client to connect to it whose connection Socket objects are then stored in a Vector <Socket> object. The server then sends back data to the connected client about the other clients connected to it. Now when the client wants to send data (like an IM) to another connected client, it has to send a request to the server specifying the client login name and the server in turn streams that particular client's Address and Port to the requesting client. The requesting client then initiates the connection with the other client and then starts a conversation. One more thing, when the client communicates it needs to send information to the server like the name by which it likes to be referenced. In this scenario the server acts like a central repository for clients to query the existence of other clients in the chat room. Each client here runs a thread that listens to incoming connections and when a connection is established, may be opens a IM window or something.
    The third option is to make the server to relay the information from one client to another. Like say, I'm connected to whoopy server and i want to send "Hello" to jackson, then i send the message (ie, Hello) along with the name of the client to which i wish to send it to (ie, jackson). The server then performs a lookup in its Vector <Socket> object and then initiates a connection with jackson and sends the information. However, this method is pretty costly in that you will be wasting a lot of processing behind the server.
    --Subhankar
    P.s. If you stumble upon any other brilliant ideas let me know.

Maybe you are looking for