0

hello I am trying to achieve something like this should give results if

where 'Robert Doug' like '%Robert'

or

where 'Robert Doug' like '%Doug Robert'

if users enters first name or last name and if it matches in that whole string it should return the record. Any help is appreciated.

SQB
  • 3,926
  • 2
  • 28
  • 49
user2158642
  • 185
  • 1
  • 1
  • 8

3 Answers3

0

Try like this

SELECT * FROM [YOUR TABLE_NAME] WHERE [COLUMN_NAME] LIKE ('%'+[USER PROMPT]+'%')
R S P
  • 997
  • 5
  • 8
0

Or try this..

SELECT PATINDEX('%Robert%',NAME_COLUMN)
FROM [YOUR TABLE_NAME]

Or..

SELECT NAME_COLUMN
FROM [YOUR TABLE_NAME]
WHERE PATINDEX('%Robert%',NAME_COLUMN)<>'0'
Leptonator
  • 3,379
  • 2
  • 38
  • 51
0

Thank you all i tried something like this

WHERE ( d_searchJobTitle.term like '%'+case when CHARINDEX(' ','implementation analyst') >0 then SUBSTRING('implementation analyst',1,CHARINDEX(' ','implementation analyst')) else 'implementation analyst' end+'%' and d_searchJobTitle.term like '%'+ case when CHARINDEX(' ','implementation analyst') >0 then SUBSTRING('implementation analyst',CHARINDEX(' ','implementation analyst'),len('implementation analyst')) else 'implementation analyst' end

+'%' )

user2158642
  • 185
  • 1
  • 1
  • 8