我正在维护一些在 Sybase 数据库查询中使用 *= 运算符的代码,但我找不到有关它的文档。有谁知道 *= 的作用是什么?我认为这是某种连接。

select * from a, b where a.id *= b.id

我不明白这与以下有何不同:

select * from a, b where a.id = b.id
有帮助吗?

解决方案

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc34982_1500/html/mig_gde/mig_gde160.htm:

内表和外表

术语“外表”和“内表”描述了外连接中表的放置:

  • 在左连接中,外表和内表分别是左表和右表。外表和内表也分别称为行保留表和空值提供表。

  • 在右连接中,外表和内表分别是右表和左表。

例如,在下面的查询中,T1是外表,T2是内表:

  • T1左连接T2
  • T2右连接T1

或者,使用 Transact-SQL 语法:

  • T1 *= T2
  • T2 =* T1

其他提示

它表示外连接,简单的 = 表示内连接。

*= is LEFT JOIN and =* is RIGHT JOIN.

(反之亦然,我一直忘记,因为我不再使用它,并且谷歌在搜索 *= 时没有帮助)

当然,你 应该 这样写:

SELECT *
FROM a
LEFT JOIN b ON b.id=a.id

a,b 语法是邪恶的。

ANSI-82 语法

select 
    * 
from 
    a
  , b 

where 
     a.id *= b.id

ANSI-92

select 
    * 
from 
   a
  left outer join b 
      on a.id = b.id
select * from a, b where a.id = b.id

要求 b.id = a.id 中存在一行才能返回答案

select * from a, b where a.id *= b.id

当 b 中没有 b.id = a.id 的行时,将用 null 填充 b 中的列。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top