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

SQL select

0 Kudos
521

Hello Experts,

I have table where one of the columns is called COL1.

Suppose this table has just one record where the column COL1 has the value 56006*.

I want to select the above record even when I look up this table for records with COL1 value = 560068.

How can I write such a query?

Thanks & Regards,

Saurabh

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Kudos
483

Alas OPEN-SQL don't allow a syntax like "dobj LIKE field+%", so you should programmatically convert your single value in a list of values, a range like

I EQ 560068

I EQ 56006

I EQ 5600

I EQ 560

I EQ 56

I EQ 5

Regards,

Raymond

7 REPLIES 7
Read only

Azeemquadri
Contributor
0 Kudos
483

In select you can use the like operator  and the % symbol.

select

col1 from itab1 where col1 like '56006%'.

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
484

Alas OPEN-SQL don't allow a syntax like "dobj LIKE field+%", so you should programmatically convert your single value in a list of values, a range like

I EQ 560068

I EQ 56006

I EQ 5600

I EQ 560

I EQ 56

I EQ 5

Regards,

Raymond

Read only

0 Kudos
483

It seems you're the only who spotted that the wildcard is a value the table!

Read only

0 Kudos
483

Yes, alas , as most people see what they expect to see, not what is written. Moreover, in this case the question would have been too basic and would have justified a "Report abuse" .

It looks like a Customizing table with wildcard and the program look for items that can be applied to a value.

Regards,

Raymond

Read only

Former Member
0 Kudos
483

Hi,

I think that this example is useful for you

   REPORT  z_example_abap.

TABLES vbak.

DATA: BEGIN OF tb_vbak OCCURS 0,
        vbeln LIKE vbak-vbeln,
        netwr LIKE vbak-netwr,
       END OF tb_vbak.


START-OF-SELECTION.
  REFRESH tb_vbak.
  CLEAR tb_vbak.
  SELECT vbeln netwr  FROM  vbak
    INTO TABLE tb_vbak
         WHERE  vbeln  LIKE '%178%'.

  DESCRIBE TABLE tb_vbak LINES sy-tfill.

END-OF-SELECTION.

Regards

Ivan

Read only

0 Kudos
483

This message was moderated.

Read only

former_member196593
Participant
0 Kudos
483

SELECT * FROM  table name INTO TABLE gt_itab WHERE COL1 LIKE '560006%'.