03-29-2006 8:37 AM
Hello guys,
Can I do Inner Join 4 or 5 tables in a select statement?
03-29-2006 8:44 AM
Hi Maui,
Basically there are no limits,You can have as many number of tables as you wish.
Regards,
Abdul Hakim
03-29-2006 8:42 AM
Maui,
Yes it is possible, however, it might have an impact on the performance.
regards,
Ravi
Note : Please mark the helpful answers.
03-29-2006 8:45 AM
YA U CAN JOIN AS MANY TABELS U REQUIRED BUT U FACE
performance PROBLEM
03-29-2006 8:47 AM
How come? How will I do it?
like:
FROM (table1 as x JOIN table2 as y
ON xf1 = yf1)
INNER JOIN table3 as a
ON af1 = xf1...
how about the 4th table?
03-29-2006 8:50 AM
03-29-2006 8:51 AM
Hi maui,
you can keep joining tables as wenceslaus did..
but is highly recommended no to use JOINS more than three times....
IN case you just want to make it ..
use FOR ALL ENTRIES..
regards
satesh
Message was edited by: Satesh R
03-29-2006 8:51 AM
U HAVE TO SERCH FOR KEY FIELD FOR THAT . MEANS HOW TABELS ARE RELATED EACH OTHE FOR THIS U ALSO USE SQ02
FOR EXAMPLE
SELECT bkpf~belnr
bkpf~gjahr
bkpf~bukrs
bkpf~blart
bkpf~bldat
bkpf~budat
bkpf~usnam
bkpf~tcode
bkpf~xblnr
bsik~lifnr
bsik~bupla
bsik~secco
INTO CORRESPONDING FIELDS OF TABLE itab_pur
FROM bkpf INNER JOIN bsik
ON bkpfbelnr = bsikbelnr
and bkpfbukrs = bsikbukrs
WHERE bkpf~bukrs IN co_code
AND bkpf~budat IN pos_dt
AND bkpf~tcode IN t_code
AND bsik~secco IN se_code.
U CAN ALSO ADD MORE TABLE BASED ON CONDITION
03-29-2006 8:52 AM
Thanks Guys! But how will the peformance affect this type of statement?
03-29-2006 8:57 AM
Hi Maui,
õ Keep the result set small!
1. E.g. use WHERE conditions
õ Minimize the amount of data transferred!
2. E.g. use field lists and aggregate functions
õ Minimize the number of transfers!
3. E.g. use joins (not more than 3)and subqueries
õ Minimize the search overhead!
4. The data base should use an appropriate index
õ Reduce the database load!
5. All users share one data base
regards
satesh
03-29-2006 8:44 AM
Hi Maui,
Basically there are no limits,You can have as many number of tables as you wish.
Regards,
Abdul Hakim
03-29-2006 8:46 AM
Yes you can do. But avoid more than 5 tables in the join.
SELECT vbak~vbeln vbak~vkorg vbak~vtweg vbak~spart vbap~posnr
vbap~matnr vbap~zmeng likp~lfart likp~lfdat lips~lfimg
FROM ( ( ( vbak INNER JOIN vbap ON vbak~vbeln = vbap~vbeln ) INNER JOIN
lips ON vbak~vbeln = lips~vgbel ) INNER JOIN likp ON likp~vbeln =
lips~vbeln ) INTO TABLE i_data where vbap~posnr = lips~vgpos
AND vbak~vbeln IN s_vbeln
03-29-2006 8:44 AM
Yes, we can do, but it may give some performance issues so btter to use For All Entries.
Ram
03-29-2006 8:46 AM
Hi
Yes,you can access data from 4 or 5 tables using Inner Join.
If you want the syntax you can ask for that.
Thanks
Mrutyunjaya Tripathy