0
votes

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

2
Your error does not match the query. There is no me FROM "Employee" t1 in the query in the question. - Gordon Linoff

2 Answers

4
votes

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
0
votes
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.