Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Like not Inner join

ertugrul_bagci
Explorer
0 Kudos

Hello, I have a problem. I want to write a SELECT query. In this query, I have data for LIKP. When I use LIKP-VERUR EQ MATDOC-XBLNR, I want the data not to come entirely if this data exists in the MATDOC for that specific row. Essentially, I need a structure that works in the exact opposite way of an inner join.

Previously, I connected with LEFT OUTER and then deleted the ones where the key field of MATDOC is filled. It worked, but I am experiencing performance issues because there is a lot of data. In my research, I think it can be solved by adding an additional SELECT within the WHERE condition, but I couldn't manage to do it.

 SELECT likp~vbeln, likp~verur
FROM likp
LEFT OUTER JOIN matdoc AS mt ON mt~xblnr EQ likp~verur
INTO TABLE @DATA(lt_items)
Where likp~vbeln EQ @p_vbeln.
DELETE lt_items WHERE key1 IS NOT INITIAL.
1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Did you try a subquery (in where condition) such as

SELECT likp~vbeln, likp~verur
  FROM likp 
  INTO TABLE @DATA(lt_items)
  WHERE NOT EXISTS( SELECT * FROM MATDOC WHERE xblnr EQ likp~verur ).

You could also try to use operator EXCEPT (but shouldn't give better performance?)

2 REPLIES 2

raymond_giuseppi
Active Contributor

Did you try a subquery (in where condition) such as

SELECT likp~vbeln, likp~verur
  FROM likp 
  INTO TABLE @DATA(lt_items)
  WHERE NOT EXISTS( SELECT * FROM MATDOC WHERE xblnr EQ likp~verur ).

You could also try to use operator EXCEPT (but shouldn't give better performance?)

0 Kudos

Thank you so much. It's working.