Home > Back-end >  SQL search last name in full name
SQL search last name in full name

Time:10-21

I'm having an issue in searching last name in full name. It is working with %% but I don't what to use it because all has 'A' are showing. Is there any alternative way on search last name? For example I have a full name John Doe and I only searched Doe, how to get the result even if I searched the last name?

SELECT * FROM Customers where CustomerName LIKE '%Doe%' - this is working

CodePudding user response:

Select * from table_name where Column_Name Like "%last_name"
  • that will select only full names ends by last_name

CodePudding user response:

Here, I am shown you. Please, try this both of one.

SELECT FullName FROM dbo.TableA where FullName LIKE '%Choksi%'

SELECT  SUBSTRING(FullName, CHARINDEX(' ', FullName)   1, LEN(FullName)) AS [Last Name]
  from dbo.TableA
 where FullName like '%Choksi%'
  • Related