Application Development and Automation 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: 
Read only

Like clause

Former Member
0 Likes
705

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
Read only

Former Member
0 Likes
685

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
Read only

Former Member
0 Likes
685

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

Read only

Former Member
0 Likes
685

use

data test type string.

CONCATENATE '%' input_param '%' INTO test.

select f1,f2 from tab1 where f3 like test.

Read only

Former Member
0 Likes
685

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

Read only

Former Member
0 Likes
686

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.

Read only

Former Member
0 Likes
685

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>