‎2009 Oct 06 11:17 AM
Hi all,
I want to use inner join with two database tables where the field from the first table can be compare to two fields from the second table.
The code as follow is syntactically not correct:
SELECT ...
INTO TABLE it_tab
FROM ZTABLE1 as a
INNER JOIN ZTABLE2 as b
ON a~PK1 = b~F1 OR a~PK1 = b~F2. "Not workMy work-around is using another temp table with same structure as it_tab. Select data two times then moves from the temp table to the it_tab table.
Please suggest me on how to use INNER JOIN without using another temp table.
Thanks,
Khanh
‎2009 Oct 06 11:24 AM
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
Make two selects adding the results in the second select to the internal table
‎2009 Oct 06 11:24 AM
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
Make two selects adding the results in the second select to the internal table
‎2009 Oct 06 11:35 AM
have you pressed F1 on join?
>Individual comparisons may be joined using AND only .
so i hope its clear that you cannot use the OR condition.
better fetch with both conditions 2 times or use FOR ALL ENTRIES
first select from ztable1 into table itab1.
then
select * from ztabl2 into table itab2
for all entries in itab1
where (f1 = itab1-f1 or f1 = itab-f2) .any ways using OR means it will separate the select into two.