SQL WHERE 子句中的加号是什么意思 (WHERE + userName = SYSTEM_USER) [英] What does a plus sign in a SQL WHERE clause (WHERE + userName = SYSTEM_USER)

查看:32
本文介绍了SQL WHERE 子句中的加号是什么意思 (WHERE + userName = SYSTEM_USER)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力寻找 where 子句中加号的含义.有没有人对此有任何想法?被卡住了一点.查询本身非常简单,使用或不使用加号的情况类似.我想删除它,除非它是有原因的.

I am stuck on trying to find the meaning of a plus sign in a where clause. Anyone have any ideas on this one? Been stuck for a bit on it. The query itself is pretty simple and work similarly with, or with without the plus sign. I'd like to remove it unless it's there for a reason.

SELECT userID from tblUser WHERE + userName = SYSTEM_USER

补充说明:这在 SQL Server 2008 中不是 Oracle,也不是来自和 Oracle 迁移......如下所述,Oracle 有一个旧的连接表示法,它使用 + 通常后缀到某些标准.

Added note: This is in SQL Server 2008 not Oracle, nor did it come from and Oracle migration... As mentioned below there is an older join notation for Oracle that uses the + generally postfixed to some of the criteria.

推荐答案

一元 + 运算符只是一个无操作.此操作员的文档中对此进行了解释,该文档位于此处:

The unary + operator is simply a no op. This is explained in the documentation for this operator, which is here:

虽然一元加号可以出现在任何数值表达式之前,但它不对表达式返回的值执行任何操作.具体来说,它不会返回负数的正值表达.要返回负表达式的正值,请使用ABS功能.

Although a unary plus can appear before any numeric expression, it performs no operation on the value returned from the expression. Specifically, it will not return the positive value of a negative expression. To return positive value of a negative expression, use the ABS function.

我实际上认为这句话有点误导.我认为一元加号运算符会将字符串参数转换为数字.当应用于填充数字的常量字符串时,这实际上是一种鼓励编译器在数字字段上使用索引的有益方式.

I actually believe this remark is a wee little bit misleading. I think the unary plus operator will convert a string argument to a number. When applied to a constant string filled with digits, this could actually be beneficial as a way of encouraging the compiler to use an index on a numeric field.

这篇关于SQL WHERE 子句中的加号是什么意思 (WHERE + userName = SYSTEM_USER)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆