Margo Stefin
Margo Stefin

Reputation: 31

CROSS JOIN in DB2

I have DB2 and I have the following Query

SELECT t1.MyName, t2.MySalary
FROM Employee t1 CROSS JOIN Salary t2

I got the following Exception :

An unexpected token "CROSS" was found following "me FROM "Employee" t1 ". Expected tokens may include: "".. SQLCODE=-104, SQLSTATE=42601

Upvotes: 0

Views: 4344

Answers (2)

Pravin Jaiswal
Pravin Jaiswal

Reputation: 1

SELECT t1.MyName, t2.MySalary
FROM Employee t1 Join Salary t2 on 1=1

The ON clause includes a condition that is always true to force the Cartesian join to occur.

Upvotes: 0

Gilbert Le Blanc
Gilbert Le Blanc

Reputation: 51445

If I understand correctly, a cross join is the Cartesian product of the two tables.

Try this query:

SELECT t1.MyName, t2.MySalary
FROM Employee t1, Salary t2

Upvotes: 4

Related Questions