This query returns a result of one record where both the [E-mail]
and [E-mail 2]
are equal to 'e'
. Most definitely the result of a lazy salesman. Any idea why this is the case though?
My query is as shown below so I should only get records where the email is equal to 'emailfromsomeone@hotmail.com'
correct?
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)
You've declared @email
to be a VARCHAR
, meaning a single VARCHAR
. When you're setting the @email
variable, it's being truncated to just the first character.
Try changing VARCHAR
to something like VARCHAR(100)
.
I got it. So i declared the variable like so and then it worked
declare @email VARCHAR(255)
sorry for bothering you stakoverflow!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.