Skip to Content
0
Former Member
May 21, 2010 at 10:32 PM

Where clause in Joins

52 Views

I have a selection screen like:

Table Field

EKKO EKORG

EKKO EKGRP

EKKO LIFNR

ESSR EBELN

ESSR EBELP

ESSR LBLNE

ESSR FRGZU

ESSR ERDAT

ESSR LOEKZ

Due to further complexities in the program i am joining 3 tables EKKO, EKPO and ESSR together. I can write the select stmt in 2 ways. I want to understand which one is better in terms of performance and is there exactly a rule here that i should follow before i write the where clause in this join.

SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni

clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu

INTO TABLE gt_test

FROM ekko AS a INNER JOIN ekpo AS b

ON aebeln = bebeln

INNER JOIN essr AS c

ON aebeln = cebeln

AND bebeln = cebeln

AND bebelp = cebelp

WHERE a~lifnr IN so_lifnr

AND a~ekorg IN so_ekorg

AND a~ekgrp IN so_ekgrp

AND c~lblne IN so_lblne

AND c~ebeln IN so_ebeln

AND c~ebelp IN so_ebelp

AND c~erdat IN so_erdat.

SELECT aebeln bebelp alifnr aekorg aekgrp bpackno c~lblni

clblne cerdat cpackno cloekz cfrgsx cfrgkl c~frgzu

INTO TABLE gt_test

FROM ekko AS a INNER JOIN ekpo AS b

ON aebeln = bebeln

INNER JOIN essr AS c

ON aebeln = cebeln

AND bebeln = cebeln

AND bebelp = cebelp

WHERE a~ebeln IN so_ebeln

AND a~lifnr IN so_lifnr

AND a~ekorg IN so_ekorg

AND a~ekgrp IN so_ekgrp

AND b~ebelp IN so_ebelp

AND c~lblne IN so_lblne

AND c~erdat IN so_erdat.

AND c~erdat IN so_erdat.