Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Like clause

Former Member
0 Kudos

Hi,

I want to use Like clause in where condition.

select f1,f2 from tab1 where f3 like '%' input_param '%'.

input_param is input parameter's value.

Please help with the syntax.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

data:

f3_pattern(256) type c.

concatenate '%' input_param '%'

into f3_pattern.

select single f1 f2

into (f1_val, f2_val)

from tab1

where f3 like f3_pattern.

Regards,

Maxim.

5 REPLIES 5

former_member181962
Active Contributor
0 Kudos

Hi Pratibha,

have a look at this example

Examples

Example to select all customers whose name begins with 'M':

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME FROM SCUSTOM

INTO CORRESPONDING FIELDS OF SCUSTOM_WA

WHERE NAME LIKE 'M%'.

WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.

ENDSELECT.

Example to select all customers whose name begins with '100%':

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME FROM SCUSTOM

INTO CORRESPONDING FIELDS OF SCUSTOM_WA

WHERE NAME LIKE '100#%' ESCAPE '#'.

WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.

ENDSELECT.

Regards,

Ravi

Former Member
0 Kudos

use

data test type string.

CONCATENATE '%' input_param '%' INTO test.

select f1,f2 from tab1 where f3 like test.

Former Member
0 Kudos

Hi,

Try the below code.

Concatenate '%' input_param '%' to test.

select sname

into dl_sname

from pa0001

where sname like Test.

endselect.

It will fetch you all the names of employees who have

TEST in their name.

Thanks & Regards,

Siri.

Message was edited by: Srilatha T

Former Member
0 Kudos

Hi!

data:

f3_pattern(256) type c.

concatenate '%' input_param '%'

into f3_pattern.

select single f1 f2

into (f1_val, f2_val)

from tab1

where f3 like f3_pattern.

Regards,

Maxim.

Former Member
0 Kudos

Hi,

data test type string.

CONCATENATE '%' input_param '%' INTO test.

<i>select f1 f2 from tab1 into (n1, n2) where f3 like test.

endselect.</i>