此查询返回一条记录的结果,其中[E-mail]
和[E-mail 2]
均等于'e'
。绝对是懒惰推销员的结果。知道为什么会这样吗?
我的查询如下所示,所以我应该只获取电子邮件等于'emailfromsomeone@hotmail.com'
正确的记录?
declare @email as varchar
set @email = 'emailfromsomeone@hotmail.com'
select
C.[No_],
C.[First Name] firstname,
C.[Surname] lastname,
C.[E-Mail] as email,
C.[E-Mail 2] as email_2,
C.[GDPR Opt-in] as GDPR_opt_in,
C.[Salesperson Code] as sales_person
from
[Contact] as C
where
lower(C.[E-Mail]) = lower(@email)
or lower(C.[E-Mail 2]) = lower(@email)
答案 0 :(得分:4)
您已宣布@email
为VARCHAR
,即单 VARCHAR
。当您设置@email
变量时,它会被截断为第一个字符。
尝试将VARCHAR
更改为VARCHAR(100)
。
答案 1 :(得分:-1)
我明白了。所以我声明变量是这样的,然后它工作
declare @email VARCHAR(255)
抱歉打扰你stakoverflow!