Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 DB2,我有以下查询
SELECT t1.MyName, t2.MySalary FROM Employee t1 CROSS JOIN Salary t2
我得到以下异常:
在“me FROM”Employee“t1”之后发现了一个意外的令牌“CROSS”。预期的标记可能包括:“”.. SQLCODE=-104, SQLSTATE=42601
如果我理解正确,交叉连接是两个表的笛卡尔积。
试试这个查询:
SELECT t1.MyName, t2.MySalary FROM Employee t1, Salary t2
SELECT t1.MyName, t2.MySalary FROM Employee t1 Join Salary t2 on 1=1
ON 子句包含一个始终为真的条件,以强制发生笛卡尔连接。