Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

how to compare and match only the first letter of a firstname column

I need to add a filter in my where clause kinda like this:

where
lastname = lname
and
"first character of" firstName = "first character of" FNAME

This way I will get a match between CHRISTOPHER SMITH and CHRIS SMITH. I have other things I am filtering on as well like phone number, zip, ect.
0
sqlagent007
Asked:
sqlagent007
  • 3
1 Solution
 
quincydudeCommented:
where SUBSTR(lastname,1,1) = SUBSTR(lname,1,1)  
0
 
quincydudeCommented:
oops.

where SUBSTR(firstName,1,1) = SUBSTR(FNAME,1,1)  
0
 
quincydudeCommented:
it should be SUBSTRING

in all

where
lastname = lname
and
SUBSTRING(firstName,1,1) = SUBSTRING(FNAME,1,1)
0
 
sqlagent007Author Commented:
LOL! I figured it out when SBSTRING didn't work. Thanks a bunch!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now