Hi,
Could someone please tell me what's wrong with these case statements (see below). Please see my comments below in the 'where' clause:
select c.Id, c.first_name, c.last_name, c.email, c.phone
from customers c
where c.type = 2
and (
case
when ((c.first_name like 'John%' and c.last_name like '%Christian%') or c.last_name like '%John Christian%')
THEN 1 -- If this returns 1, I want the rest of the 'else' block below to skip, how do I do that?
else -- This 'else' block for some reason is always running even though tht above 'THEN' returns 1
case
when (c.first_name like 'John%' or c.last_name like '%Christian%')
then 1
else 0
end
end = 1
)
Many thanks in advance.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.