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

select statment - where condition

Former Member
0 Likes
1,112

Hi,

i have data in a table where for a field it has data ending with 123, 124, 125 etc .

in my select query i want to select data based on the ending data like 123, 124 , 125 .

example : abc123, xyz123 . i need to pull all data ending with 123.

how do i write that in my select statment .

can anyone let me know . thanks in advance.

Ry.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,090

Hi,

Please try this.


concatenate '%' var1 into var2.

SELECT * 
FROM <ztable> 
INTO TABLE <itab> 
WHERE <field1> = var1 
  AND <field2> like var2.

Regards,

Ferry Lianto

Please reward points if helpful.

7 REPLIES 7
Read only

Former Member
0 Likes
1,090

Hi,

Use LIKE statement..

Ex..

SELECT * FROM xxx

WHERE field LIKE '%123'.

Thanks,

Naren

Read only

0 Likes
1,090

naren ,

thank you for the reply , the problem is i am passing this 123 into a character field .

ex: 123 to VAR

so in my query i gave as '%VAR'. the query was unsucessful . am i missing something , let me know

Regards,

Ry

Read only

Former Member
0 Likes
1,090

Hi,

Please try this.


RANGES: R_FIELD FOR ZTABLE-FIELD.

R_FIELD-SIGN = 'I'.
R_FIELD-OPTION = 'CP'.
R_FIELD-LOW = '*123'.
APPEND R_FIELD.

R_FIELD-SIGN = 'I'.
R_FIELD-OPTION = 'CP'.
R_FIELD-LOW = '*124'.
APPEND R_FIELD.

R_FIELD-SIGN = 'I'.
R_FIELD-OPTION = 'CP'.
R_FIELD-LOW = '*125'.
APPEND R_FIELD.

SELECT FIELD 
INTO TABLE ITAB
FROM ZTABLE
WHERE FIELD IN R_FIELD.

Regards,

Ferry Lianto

Read only

0 Likes
1,090

Hi Ferry Lianto ,

thank you for your reply my req is like this

move *123 into Var2. this is of char type C .

SELECT * FROM <table > INTO ,itab> WHERE <table-field> = var1 AND <table-field1> = ' %var2' .

but this is not working , can you let me know where exactly is the issue .

Read only

Former Member
0 Likes
1,090

Hi,

Pleas try this.



data: var2 like ztable-field2.

move '%123' to var2.
 
SELECT * 
FROM <ztable> 
INTO TABLE <itab> 
WHERE <field1> = var1 
  AND <field2> like var2.

Regards,

Ferry Lianto

Read only

0 Likes
1,090

Ferry,

Here i have to move '%var1' to var2 as var1 is dynamic value .

so i am not able to populate the content of the variable.

can you help me out on this .

Ry.

Read only

Former Member
0 Likes
1,091

Hi,

Please try this.


concatenate '%' var1 into var2.

SELECT * 
FROM <ztable> 
INTO TABLE <itab> 
WHERE <field1> = var1 
  AND <field2> like var2.

Regards,

Ferry Lianto

Please reward points if helpful.