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: 

How to select a part of the filed in SELECT??

Former Member
0 Kudos

Hi all,

I want to get a part in the field of table to compare with a string. But the LIKE syntax is poor efficiency. Who can give another way. thx in advance.

Eg:

SELECT *

FROM TAB1

INTO IT_TAB1

WHERE FIELD1 = '2008'.

But in the FIELD1 is '2008AAAA', I want to compare '2008' with the frontal 4 char.

6 REPLIES 6

Former Member
0 Kudos

Hi,

You can try with '2008*'.

Regards,

Kunjal

Former Member
0 Kudos

Hi Steven,


SELECT *
FROM TAB1
INTO IT_TAB1
WHERE FIELD1+0(4) = '2008'.

Hope this helps you.

Regards,

Kiran

Former Member
0 Kudos

Hi,

Try like this....


SELECT * INTO TABLE IT_TAB1 FROM TAB1 WHERE FIELD1(4) = '2008'.

Hope it will helps

Former Member
0 Kudos

fine.

Move first 4 characters to a variable and use it in where condition.

eg: concatenate field1(4) into field2.

use field2 in select stmt.

It increases performance also.

regards,

Padmashree.

Edited by: Padmashree RamMaghenthar on Sep 23, 2008 3:10 PM

Former Member
0 Kudos

HI,

Try out this.

data : var(4) type c value '2008'.

SELECT *

FROM TAB1

INTO IT_TAB1

WHERE FIELD1 like var%.

Thanks.

Swati.

Former Member
0 Kudos

First check in database based on '2008' are you getting records or not, if yes then you have to use mentioned logic

FIELD1 = FIELD1+0(4).

and FIELD1 to select statement.

Rajneesh Gupta