terri333
terri333

Reputation: 37

Use the LIKE operator with the value of a text field in APEX

I currently have this select statement

Select fullName
From mytable
Where fullName = :P32_Full_Name

:P32_Full_Name = the string that the user typed in the search box

I want to be able to use the LIKE operator using the :P32_Full_Name.

for example:

Select fullName
From mytable
Where fullName Like '%:P32_Full_Name%'

As you can see from the query above I am just trying to select from table the Full_Name that contains the characters typed by the user. If I leave it without the Like operator as in the first query and the user types 'Kimberly Clark' the query will not work because the table has 'Kimberly Clark Jr.'

Any suggestion is welcome!

Upvotes: 0

Views: 766

Answers (2)

Littlefoot
Littlefoot

Reputation: 142743

Alternatively: instead of LIKE, you could try with INSTR:

where instr(fullName, :P32_FULL_NAME) > 0

Upvotes: 0

Scott
Scott

Reputation: 5035

I think you're chasing

'%'||:P32_FULL_NAME||'%'

Upvotes: 1

Related Questions