Application Development and Automation 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: 
Read only

Like not Inner join

ertugrul_bagci
Explorer
0 Likes
1,662

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
Read only

RaymondGiuseppi
Active Contributor
1,601

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?)

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.
2 REPLIES 2
Read only

RaymondGiuseppi
Active Contributor
1,602

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?)

Read only

0 Likes
1,601

Thank you so much. It's working.