-1

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

carch
  • 217
  • 4
  • 18
  • So if the customer name is `Doe John`, you don't want to get his result? – Arulkumar Oct 20 '21 at 09:57
  • @Arulkumar i still want to get the result either way even if John Doe or Doe John – carch Oct 20 '21 at 09:59
  • 1
    Does this answer your question? [Match only entire words with LIKE?](https://stackoverflow.com/questions/6283767/match-only-entire-words-with-like) – C4stor Oct 20 '21 at 10:02

2 Answers2

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

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%'
Jaynil Choksi
  • 9
  • 1
  • 10