[英]Why use “=+” and “=*” in “WHERE ” clause?
I have issue related database connection in java class,i don't know why use this "=+" and "=*" in "WHERE " clause. 我在java类中有问题相关的数据库连接,我不知道为什么在“WHERE”子句中使用这个“= +”和“= *”。
Here's an example: 这是一个例子:
String where = null;
if (isOracleConnectionCache()) {
where = "ValidInfo.InfoCode = FolderInfo.InfoCode AND ValidInfoGroup.InfoGroup =+ ValidInfo.InfoGroup AND FolderInfo.FolderRSN = ?";
} else {
where = "ValidInfo.InfoCode = FolderInfo.InfoCode AND ValidInfoGroup.InfoGroup =* ValidInfo.InfoGroup AND FolderInfo.FolderRSN = ?";
}
Can anyone tell me ? 有人能告诉我吗?
I have three question : 我有三个问题:
(1) What do "*" and "+" signs denote ? (1)“*”和“+”符号表示什么?
(2) how do these =+
and =*
work in the WHERE clause ? (2)这些
=+
和=*
如何在WHERE子句中起作用?
(3)how it is compare with two table ? (3)如何与两个表比较?
So, as already explained by others, the =*
operator in SQL Server indicates an outer join. 因此,正如其他人已经解释过的那样,SQL Server中的
=*
运算符表示外连接。
However, in Oracle =+
is not an operator at all. 但是,在Oracle
=+
根本不是运算符。 It appears that ValidInfoGroup.InfoGroup =+ ValidInfo.InfoGroup
is actually parsed as ValidInfoGroup.InfoGroup = (+ ValidInfo.InfoGroup)
, where +
is the unary identity operator. 似乎
ValidInfoGroup.InfoGroup =+ ValidInfo.InfoGroup
实际上被解析为ValidInfoGroup.InfoGroup = (+ ValidInfo.InfoGroup)
,其中+
是一元身份运算符。
Since this code appears to be an attempt to write an outer join depending on which database is being used, it is incorrect when used in Oracle - it is actually doing a normal join. 由于此代码似乎是尝试根据正在使用的数据库编写外部联接,因此在Oracle中使用时它是不正确的 - 它实际上正在进行正常连接。 The proper way to write this condition in Oracle's custom syntax would be
ValidInfoGroup.InfoGroup = ValidInfo.InfoGroup (+)
. 在Oracle的自定义语法中编写此条件的正确方法是
ValidInfoGroup.InfoGroup = ValidInfo.InfoGroup (+)
。
It would perhaps be better to use ANSI SQL join syntax to indicate the outer join, which I believe would remove the need to test which database is being used. 使用ANSI SQL连接语法来指示外连接可能会更好,我相信这将消除测试正在使用哪个数据库的需要。
Thanks to Martin and Nicholas for helpful comments on the other answers. 感谢Martin和Nicholas对其他答案的有益评论。
=*
does OUTER JOIN in SQL Server =*
在SQL Server中进行OUTER JOIN
UPDATE UPDATE
(+)
= does OUTER JOIN in Oracle (+)
=在Oracle中进行OUTER JOIN
I dont know what =+ does sorry for the confusion 我不知道= +为这种困惑感到遗憾
这只不过是Oracle和MS-SQL中的外部连接让我们假设我删除了一个表记录并且相应的值为NULL所以当你从我的理解中比较==
时会产生问题所以我们可以像你提到的那样使用外连接在你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.