我是否将 Ansi OUTER JOIN 语法正确转换为较旧的 Sybase (*=) 连接语法?

发布于 2024-07-23 09:09:56 字数 844 浏览 6 评论 0原文

假设这是左外连接的正确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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

躲猫猫 2024-07-30 09:09:56

*= 相当于左外连接,而 ... =* 相当于右外连接(正如您所猜测的)

您可能有兴趣注意到,有旧版本的 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)

っ〆星空下的拥抱 2024-07-30 09:09:56

是的。 但有时这两个在处理结果集时可能会有点不同

yes. but sometimes these two may be a little different when handling set of result by where

情愿 2024-07-30 09:09:56

对,那是正确的

Yes, that is correct

丑疤怪 2024-07-30 09:09:56

为什么要从左连接转换为旧语法,难道不应该从旧语法转换为首选的新标准吗? 我不了解 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文