我是否将 Ansi OUTER JOIN 语法正确转换为较旧的 Sybase (*=) 连接语法?
假设这是左外连接的正确Ansi SQL语法:
SELECT *
FROM employee LEFT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
这是右外连接的正确Ansi SQL语法join:
SELECT *
FROM employee RIGHT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
这是旧版Sybase 相当于左外连接吗:
SELECT * FROM employee, department
WHERE employee.DepartmentID *= department.DepartmentID
这是旧版Sybase 相当于右外连接:
SELECT * FROM employee, department
WHERE employee.DepartmentID =* department.DepartmentID
因此,对于左外连接,我们将 * 放在等号的左侧;对于右外连接,我们将 * 放在等号的右侧。
那是对的吗?
Assuming this is the correct Ansi SQL syntax for a left outer join:
SELECT *
FROM employee LEFT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
And this is the correct Ansi SQL syntax for a right outer join:
SELECT *
FROM employee RIGHT OUTER JOIN department
ON employee.DepartmentID = department.DepartmentID
Is this the older Sybase equivalent of a left outer join:
SELECT * FROM employee, department
WHERE employee.DepartmentID *= department.DepartmentID
And this the older Sybase equivalent of a right outer join:
SELECT * FROM employee, department
WHERE employee.DepartmentID =* department.DepartmentID
So we put the * on the left side of the equals sign for a left outer join and on the right side of the equals sign for a right outer join.
Is that correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
*=
相当于左外连接,而 ...=*
相当于右外连接(正如您所猜测的)您可能有兴趣注意到,有旧版本的 Sybase ASE 不支持
*=*
。 Transact-SQL 外连接的语义和兼容性解释了原因 (PDF)*=
is equivalent to a left outer join and ...=*
to a right outer join (as you'd have guessed)You may be interested to note that there is no support for
*=*
in older releases of Sybase ASE. Semantics and compatibility of Transact-SQL outer joins explains why (PDF)是的。 但有时这两个在处理结果集时可能会有点不同
yes. but sometimes these two may be a little different when handling set of result by where
对,那是正确的
Yes, that is correct
为什么要从左连接转换为旧语法,难道不应该从旧语法转换为首选的新标准吗? 我不了解 Sybase,但由于 SQl Server 基于 Sybase,我怀疑它可能存在相同的问题,即旧语法并不总是正确解释为外连接。 有时,数据库可能会将其解释为交叉联接,因此一般来说,我不建议使用它,除非您正在访问旧版本的数据库,以致新语法不可用。
Why would you be translating from left join to the older syntax, shouldn't you be translating from the older syntax to the preferred newer standard? I don't know about Sybase but since SQl Server is based on Sybase, I suspect it might have the same problem which is that the older syntax does not always correctly get intepreted as an outer join. At times the database might interpret it as a cross join, so in general I don't recommend using it unless you are accessing a database in such an old version that the newer syntax is not available.