join conditions are more flexible.
Please follow the underlined and red colored way in syntx diagrams.
subselect - IBM DB2 9.7 for Linux, UNIX, and Windows
Code:
joined-table
.-INNER-----.
>>-+-table-reference--+-----------+--JOIN--table-reference--ON--join-condition-+-><
| '-| outer |-' |
+-table-reference--CROSS JOIN--table-reference------------------------------+
'-(--joined-table--)--------------------------------------------------------'
outer
.-OUTER-.
|--+-LEFT--+--+-------+-----------------------------------------|
+-RIGHT-+
'-FULL--'
Note: I'll omit
table-reference to simplify the references.
Code:
A join-condition is a search-condition, except that:
•It cannot contain any subqueries, scalar or otherwise
•It cannot include any dereference operations or the DEREF function, where the reference value is other than the object identifier column
•It cannot include an SQL function
•Any column referenced in an expression of the join-condition must be a column of one of the operand tables of the associated join (in the scope of the same joined-table clause)
•Any function referenced in an expression of the join-condition of a full outer join must be deterministic and have no external action
•It cannot include an XMLQUERY or XMLEXISTS expression
An error occurs if the join condition does not comply with these rules (SQLSTATE 42972).
Search conditions - IBM DB2 9.7 for Linux, UNIX, and Windows
Code:
search-condition
|--+-----+--+-predicate--+-------------------------------+-+---->
'-NOT-' | '-SELECTIVITY--numeric-constant-' |
'-(search-condition)---------------------------'
.------------------------------------------------------------------------.
V |
>----+--------------------------------------------------------------------+-+--|
'-+-AND-+--+-----+--+-predicate--+-------------------------------+-+-'
'-OR--' '-NOT-' | '-SELECTIVITY--numeric-constant-' |
'-(search-condition)---------------------------'
Basic predicate - IBM DB2 9.7 for Linux, UNIX, and Windows
Code:
Basic predicate
>>-expression--+- = ------+----expression----------------------><
| (1) |
+- <> -----+
+- < ------+
+- > ------+
| (1) |
+- <= -----+
| (1) |
'- >= -----'
Expressions - IBM DB2 9.7 for Linux, UNIX, and Windows
Code:
expression
.-operator--------------------------------------.
V (1) |
|------+-----+--+-function-invocation--------------+-+----------|
+- + -+ +-(expression)---------------------+
'- - -' | (2) |
+-constant-------------------------+
+-column-name----------------------+
| (3) |
+-variable-------------------------+
| (4) |
+-special-register-----------------+
| (5) |
+-scalar-fullselect----------------+
| (6) |
+-labeled-duration-----------------+
| (7) |
+-case-expression------------------+
| (8) |
+-cast-specification---------------+
| (9) |
+-field-reference------------------+
| (10) |
+-xmlcast-specification------------+
| (11) |
+-array-element-specification------+
| (12) |
+-array-constructor----------------+
| (13) |
+-dereference-operation------------+
| (14) |
+-method-invocation----------------+
| (15) |
+-OLAP-specification---------------+
| (16) |
+-row-change-expression------------+
| (17) |
+-sequence-reference---------------+
| (18) |
'-subtype-treatment----------------'
As a consequence, try...
Table1 AS t1 INNER JOIN Table2 AS t2 ON LOCATE(t2.col , t1.col2) > 0
If you are using older version of DB2 and got error, try...
Table1 AS t1 INNER JOIN Table2 AS t2 ON SYSFUN.LOCATE(t2.col , t1.col2) > 0