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: 

SQL select

0 Kudos

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

raymond_giuseppi
Active Contributor
0 Kudos

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

Azeemquadri
Contributor
0 Kudos

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

select

col1 from itab1 where col1 like '56006%'.

raymond_giuseppi
Active Contributor
0 Kudos

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

0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

This message was moderated.

former_member196593
Participant
0 Kudos

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