11-14-2005 9:06 AM
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
11-14-2005 9:16 AM
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.
11-14-2005 9:10 AM
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
11-14-2005 9:12 AM
use
data test type string.
CONCATENATE '%' input_param '%' INTO test.
select f1,f2 from tab1 where f3 like test.
11-14-2005 9:13 AM
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
11-14-2005 9:16 AM
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.
11-14-2005 9:18 AM
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>