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 in a SELECT statement

Former Member
0 Likes
507

Is it possible to use LIKE keyword in a SELECT statement more than once? If not, is there any alternate way of doing this? I am not getting anything returned when I use it twice on the same field.

I have a table CDPOS with field TABKEY which is 70 CHAR long.

Value of field TABKEY in table CDPOS = '00003001001PR00'

LINEITEM = '000030%'

CONDITION = 'PR00%'

I used the following select statement to retrieve the above CDPOS value..

select objectid changenr from cdpos into table tmp_cdpos

where tabkey like LINEITEM and tabkey like CONDITION.

If I use just 'lineitem' with the LIKE, it works but adding 'tabkey' results in no hits.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
483

Try:

SELECT * FROM cdpos
  WHERE tabkey LIKE '000030_____PR00%'.    <== Underscores

Rob

4 REPLIES 4
Read only

Former Member
0 Likes
483

Use OR instead of AND in the select statement then it works.

select objectid changenr from cdpos into table tmp_cdpos

where tabkey like LINEITEM

OR tabkey like CONDITION.

Thanks

Srinivas

Read only

Former Member
0 Likes
483

change CONDITION = 'PR00%'

to CONDITION = '%PR00'

The % represents the variable portion of the condition.

Read only

Former Member
0 Likes
484

Try:

SELECT * FROM cdpos
  WHERE tabkey LIKE '000030_____PR00%'.    <== Underscores

Rob

Read only

Former Member
0 Likes
483

Thank You, Rob. Your solution worked.

Anjana