Using LIKE in Select query

Hi experts,
I am writing a Function module to get data from a table.
Import :
desc TYPE ZTABLE-DESCRIPTION.
Now when desc = te*
REPLACE ALL OCCURRENCES OF '*' IN
       desc WITH '%' .
SELECT *
    FROM ZTABLE
    INTO CORRESPONDING FIELDS OF TABLE t_list WHERE DESCRIPTION LIKE desc.
.. With is the table fetches all records where description starts with " te " ..  here te is case senstive
So if description is "Test " or " TEST " or "tE" ......... so on.. i want this like to be made case in sensitive
Coz user can search as per his/her way...
Regards,
Bijal

e_sel-sign = 'I'.
e_sel-option = 'BT'.
e_sel-low = 'te%'.
e_sel-high = 'TE%'.
APPEND e_sel TO i_sel .clear e_sel.
e_sel-sign = 'I'.
e_sel-option = 'BT'.
e_sel-low = 'tE%'.
e_sel-high = 'Te%'.
APPEND e_sel TO i_sel .clear e_sel.
SELECT *
FROM ztable
INTO CORRESPONDING FIELDS OF TABLE t_list
WHERE description IN i_sel.
or
SELECT *
FROM ztable
INTO CORRESPONDING FIELDS OF TABLE t_list
WHERE description+0(2) in ( 'te%', 'TE%' , 'Te%', 'tE%').

Similar Messages

  • Using like with select clause

    Hi experts,
    I have a problem where i feel i should catch filtered resultset on to my internal table and i feel using LIKE.
    But if i use LIKE '%AMIT%'
    will it store
    AMIT
    amit
    Amit  ie all possible combination irrespectin of any case ?
    Will it be case insenstive or not ?

    HI,
    using like in select is case sensitive.
    do like this for ignoring the case.
    TABLES:mara.
    SELECT * from mara.
      IF mara-matnr cp 'm*'.
        WRITE:/ mara-matnr.
      ENDIF.
    ENDSELECT.
    rgds,
    bharat.

  • Like with select query

    Hi,
    I have a query something like ...
    Select ....
    where
    b.prodname like 'SHAFT GEAR%' or b.prodname like '%FRONT GEAR%' or b.prodname like '%BREAK 4K%'
    and
    b.prodname like
    (select company name from companyms
    where <some comdition>
    order by 3,6
    I am stucking at :
    b.prodname like
    (select company name from companyms
    where <some comdition>
    i.e. how do I give select query with like operator.
    In above query I want b.prodname like above and those company name for which I am giving condition.  Company names are stored in other table and I want to select and use them with like operator.
    Thanks.

    create table stock
    prodname varchar2(50)
    insert into stock values ('MICRO FRONT PANEL');
    insert into stock values ('ZEBRA FRONT SHAFT');
    insert into stock values ('KOBRA SHAFT GEAR');
    insert into stock values ('T RUBBER TUBES');
    insert into stock values ('MICRO TUBES PANELS');
    insert into stock values ('HEFT SHAFT GEAR');
    SELECT * FROM STOCK;
    PRODNAME
    MICRO FRONT PANEL
    ZEBRA FRONT SHAFT
    KOBRA SHAFT GEAR
    T RUBBER TUBES
    MICRO TUBES PANELS
    HEFT SHAFT GEAR
    6 rows selected.
    create table companyms
    company_name varchar2(50)
    insert into companyms values ('MICRO');
    insert into companyms values ('CHOPRA');
    insert into companyms values ('H.P.');
    insert into companyms values ('T');
    insert into companyms values ('BEST BROTHERS');
    insert into companyms values ('FIVE STAR');
    SELECT * FROM COMPANYMS;
    COMPANY_NAME
    MICRO
    CHOPRA
    H.P.
    T
    BEST BROTHERS
    FIVE STAR
    6 rows selected.
    Actually I have little big query which have inner join with couple of more tables and suppose query returned me to select those rows who have SHAFT GEAR or FRONT GEAR or BREAK 4K of MICRO or ZEBRO or ABC company.
    So, I have query like :
    select ...
    .... some inner join...
    .... some outer join
    .... some union
    SOME MORE WHERE CLAUSES ... ETC. ETC...
    where b.prodname (b means stock table) like 'SHAFT GEAR%' or 'FRONT PANEL%'
    FOR MICRO or ZEBRA or ABC company.

  • How can i use index in select query.. facing problem with the select query.

    Hi Friends,
    I am facing a serious problem in one of the select query. It is taking a lot of time to fetch data in Production Scenario.
    Here is the query:
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelat LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelatrprctr
        WHERE rldnr  = c_telstra_accounting
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          And rzzlstar in r_lstar                            
          AND rpmax  = c_max_period.
    There are 5 indices present for Table ZTFTELAT.
    Indices of ZTFTELAT:
      Name   Description                                               
      0        Primary key( RCLNT,RLDNR,RRCTY,RVERS,RYEAR,ROBJNR,SOBJNR,RTCUR,RUNIT,DRCRK,RPMAX)                                          
      005    Profit (RCLNT,RPRCTR)
      1        Ledger, company code, account (RLDNR,RBUKRS, RACCT)                                
      2        Ledger, company code, cost center (RLDNR, RBUKRS,RCNTR)                           
      3        Account, cost center (RACCT,RCNTR)                                        
      4        RCLNT/RLDNR/RRCTY/RVERS/RYEAR/RZZAUFNR                        
      Z01    Activity Type, Account (RZZLSTAR,RACCT)                                        
      Z02    RYEAR-RBUKRS- RZZZBER-RLDNR       
    Can anyone help me out why it is taking so much time and how we can reduce it ? and also tell me if I want to use index number 1 then how can I use?
    Thanks in advance.

    Hi Shiva,
    I am using two more select queries with the same manner ....
    here are the other two select query :
    ***************1************************
    SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelpt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelptrprctr
        WHERE rldnr  = c_telstra_projects
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar             
          AND rpmax  = c_max_period.
    and the second one is
    *************************2************************
      SELECT * APPENDING CORRESPONDING FIELDS OF TABLE tbl_summary
        FROM ztftelnt LEFT JOIN ztfzberep
         ON  ztfzberep~gjahr = st_input-gjahr
         AND ztfzberep~poper = st_input-poper
         AND ztfzberepcntr  = ztftelntrprctr
        WHERE rldnr  = c_telstra_networks
          AND rrcty  = c_actual
          AND rvers  = c_ver_001
          AND rbukrs = st_input-bukrs
          AND racct  = st_input-saknr
          AND ryear  = st_input-gjahr
          and rzzlstar in r_lstar                              
          AND rpmax  = c_max_period.
    for both the above table program is taking very less time .... although both the table used in above queries have similar amount of data. And i can not remove the APPENDING CORRESPONDING. because i have to append the data after fetching from the tables.  if i will not use it will delete all the data fetched earlier.
    Thanks on advanced......
    Sourabh

  • How to use offset in select query

    Suppose i have data like ssonje     00000001 as a one field in database table . i have to segregate this two data. how should I do this.the first part is of 12 characters and the last is of 10 character long.

    Hi Naveen,
    I am again in trouble, Now the requirement were changed. I am sending you the code which i had implemented.
    Now, the user enter username(ie UNAMED) and document id (ie. TEMPD) and the output should be doucment id, which has been search through database table RFDT , field SRTFD, this field contains both the username and the document id.
    That means: suppose user enters UNAMED as SSONJE and TEMPD as 0000000030, then i want to fier the select query from RFDT on field SRTFD and get only the document id of that user which user enter on input field-UNAMED.
    i had tried but result were not coming.
    please go through the code.
    data:uname type UF05A-UNAMD.
    data:temp type UF05A-TEMPD.
    TYPES: BEGIN OF TEITAB_RFDT,
           SRTFD TYPE RFDT-SRTFD,
           END OF TEITAB_RFDT.
    DATA: ITAB_RFDT TYPE TABLE OF TEITAB_RFDT.
    DATA: WA_RFDT TYPE TEITAB_RFDT.
    DATA: STR(22) TYPE c.
    SELECT-OPTIONS:UNAMED FOR uname,
    TEMPD FOR TEMP.
    UNAMED-option = 'CP'.
    append UNAMED.
    CONCATENATE UNAMED TEMPD INTO STR.
    SELECT SRTFD FROM RFDT INTO CORRESPONDING FIELDS OF TABLE ITAB_RFDT WHERE SRTFD eq str.
    LOOP AT ITAB_RFDT INTO WA_RFDT.
    SPLIT WA_RFDT AT SPACE INTO STR1 STR2.
      WRITE: / STR1,STR2.
    ENDLOOP.
    Please mentioned what is the way to do this.
    Thanks

  • Using LIKE in SELECT ..... WHERE

    Hi,
        I need to do pattern matching during SELECT so that a table field contains or is the same as an input variable. How can I accomplish this?
    Regards,
    Nanditha

    Here is the "help" for the syntax of LIKE in SELECT statement.
    <i>
    f [NOT] LIKE g
    Addition:
    ... ESCAPE h
    Effect
    The condition is met for a table entry if the statement "f (does not) equal the pattern in g" is true for the values of f and g. f must always be a field descriptor, and g an ABAP field. If f has the value NULL, then the result of the check for the statement is unknown. Within a pattern, there are two special characters:
    '_' (underscore) stands for any single character.
    '%' (percentage sign) stands for any sequence of characters, including an empty string.
    Examples
    Example to select all customers whose name begins with 'M':
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME LIKE 'M%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Example to select all customers whose name contains 'huber':
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME LIKE '%huber%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Example to select all customers whose name does not contain 'n' as the second character:
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME NOT LIKE '_n%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Notes
    LIKE can only be used for alphanumeric database fields. In other words, table field f must have Dictionary type ACCP, CHAR, CLNT, CUKY, LCHR, NUMC, UNIT, VARC, TIMS or DATS. The comparison field g must always have type C.
    The maximum length of the pattern is 2n - 1 characters, where n is the length of field f.
    Trailing spaces are ignored in comparison field g. If a pattern contains trailing spaces, you must enclose it in single inverted commas ('). If your pattern is enclosed in inverted commas and you also want to include inverted commas as part of the pattern, the inverted commas in the pattern must be doubled.
    You cannot use this variant in the ON addition to the FROM clause.
    </i>
    Regards,
    Rich Heilman

  • Need to use Hint for Select Query  11g

    Hi,
    I have a select query which is fetching data from multiple table.
    I just need 10 or less rows, already I m using rownum <=10
    Could you tell which is the better choice for using HINT.
    /*+ FIRST_ROWS(10) */      (or)    /*+ all_rows */
    Thanks.

    On Oracle 11.2.0.3 and 11.1.0.7 on my test table with an ORDER BY in the query, I found FIRST_ROWS using the index to get sorted rows and ALL_ROWS retrieving 10 rows from a full scan and then sorting them.
    On Oracle  I didn't find any difference in plan on a different, physically smaller, table.
    For the ALL_ROWS version the optimiser already knows that there will only be 10 rows returned.
    The performance difference: As usual, only use FIRST_ROWS if you actually intend to fetch less than the full data set. If you intend to fetch all 10 rows, use ALL_ROWS, which should be the default (taken from the optimizer_mode system parameter).

  • (view hint or Query  writing method) using views in Select Query

    Need Assistance,
    Hi all,
    My database having many views. while i am joining the views in a select query increase the cost of the querys due to the complex joins in the conditions.
    While checking the select query with views individualy taking less cost.
    Does any hint or query writing method is availabe to avoid the merging of the execution plan of the views?
    I have browsed many related to the mentioned issues,couldn't found any thing that helps me.
    Please help me on this issue,it will be very much helpfull for me.
    Thanks,
    Senthur

    Please read the two threads linked to in the FAQ: {message:id=9360003} and post the relevant details they request, so that people can help you better with your issue.
    We cannot help if you just say "my query is slow what do I do to fix it" as we cannot see your queries, your data, or any other information we would need to help. If the answer was that simple, it would be built into oracle so that the optimiser would fix it for you.

  • CreateNativeQuery using parameter in select LIKE statement

    Can I use setParameter on native query (createNativeQuery) using LIKE in select statement?
    I have the following code and it doesn't work:
    Query qry = manager.createNativeQuery("Select * from Type as t where t.typeid LIKE '%?1%'", Type.class);
    qry.setParameter(1, "2");
    Thanks.

    You could do this using the CONCAT function (+ ||, depending on the database). i.e. concat '%' + ?1 + '%'. You can do this in a native query, but JPQL does not allow functions in like (although some providers may support it). If your using TopLink Essentials or (TopLink/EclipseLink) you can do this using an Expression query.
    But, in general it may be better and easier to just concat "%" to your argument.
    -- James : [http://www.eclipselink.org]

  • How to pass variable into lov sql query using like operator

    hi.
    i want to use a lov where i want to pass a variable using like operator.
    my query is
    select empno,name from table where empno like ':ed%';
    my empno is A001 TO A199 AND B001 TO B199 so i want show either A% or B% empno
    how can i do this ?
    reagrds

    kindly press Shift+F1 at a time you face this error to see the exact Oracle error message.
    and provide us with that detail
    and its better if you start new topic for that error... because that will be new error,,,
    -- Aamir Arif
    Edited by: Aamiz on Apr 7, 2010 12:27 PM

  • Joining two tables having no common fields using one select query

    Hi Experts,
    How to join two tables which are NOT having any field in common using only one select query?
    Your help will be appreciated.
    Thank you.

    Identify a third table (or more tables) with common fields with your two tables, or change your question either removing JOIN or removing NO COMMON FIELDS, else you wont get many responses and will be left alone in outer space, as suggested by Thomas.
    If you acturally require what you written, better execute two select and merge the two internal tables merging every record from first table with every record of second table, til no more memory is available.
    Regards,
    Raymond

  • Reg select query problem

    hi all,
    hope all r doing fine?
    anyway i have a query which is mentioned below:-
    select field1,.....fieldn
             from <dbtable1>
             into corresponding fields of table itab
             where <condition>.
    select field1,...fieldn
              from <dbtable2>
             appending corresponding fields of table itab
            where <condition>.
    the above two select stmts retrieve same set of  fields from two different database tables into same internal table itab..
    now my question is ...........is any other way to change 2nd select statement without using appending correspondin fields
    but the functionality should remain the same as it is after changing..................
    bcos appending corresponding is causing performance problem in data retrieval.
    thanx alot in advance.
    for sure points will be given for all the helpful answers
    Jack

    Hi,
    You can use like that:
    select field1,.....fieldn
    from <dbtable1>
    into corresponding fields of table itab1
    where <condition>.
    select field1,...fieldn
    from <dbtable2>
    appending corresponding fields of table itab2
    where <condition>.
    now u use:
    loop at itab2 into w_itab2.
    read table itab1 into w_itab1 with key w_itab1-<primary field> = w_itab2-<Primary field>.
    if sy-subrc = 0.
      append w_final into i_final.
    else continue.
    endif.
    endloop.
    *i_final table having all data ( i.e itab2 & itab1 data)

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • Cursor in select query

    how i use cursor in select query ?
    I have 2 table
    1. emp
    2. dept
    i want output like
    Manager
    a
    b
    c
    Clark
    d
    e
    f
    HOD
    g
    h
    i
    by using cursor

    We wouldn't help you to learn something if we just give you an answer.
    Show some effort by yourself first, then ask what specific problem you encountered and you'll find this forum much more willingness to help.

  • Unexpected behavior on 5.1.19 Select query

    Hello There,
    We are seeing an unexpected behavior on 11.2.5.1.19 where we are expecting our query should response “X” number of records while it response us back with less number of records in some situation. While looking to the change log we did notice that a fix has been added to 11.2.5.1.25 as follows:
    “Fixed a bug that would return DB_NOTFOUND while searching for an existing item using a cursor on a non-sorted duplicate btree database. [#19210]”
    We were wondering whether that fix could resolve this issue or not? If yes, is there a way we can get a Patch to apply and validate so that we can move to 11.2.5.1.25 or newer versions.
    Here is what we are doing, Within an application we have two threads, One is Inserting/Updating record in the table while the other one is selecting, and all DB operations are done in transaction. Select thread comes after certain time whenever a condition is satisfied. Although it work fine most of the time but there are situation where select response with fewer records that we expected, that causes our program to died as expected. However, if we query the Database (using dbsql) after the application died using the same select query/criteria we could able to select the exact same number of records that we were expecting to see. We are not sure what is going wrong here, any help is appreciated.
    Regards & Thanks

    Hi Rittick,
    I have made some modifications to the example program ex_sql_multi_thread.c,
    based on the information you sent in email. So far I can not reproduce the
    problem either. This does look like something we have seen before:
    Berkeley DB lost data sometimes when I ran the example ex_sql_multi_thread
    but it is difficult to pinpoint without an exact reproducer. One thought is
    if you can try the application with the latest Berkeley DB release which
    is: 5.3.15. Some race conditions were fixed in that release and since you can
    reproduce the behavior with 5.1 and 5.2 you should be able to verify if
    it is present or not in 5.3.15.
    Thanks,
    Sandra

Maybe you are looking for

  • No update for MFBF posting in COPA

    Hi, For all posting  under transaction MFBF, no document has been updated in profitability segment(COPA).All FI - COPA differences have been poted manually in COPA.I have checked  that Cost Element which has defined in OKB9 as aprofitability segment

  • JDK 1.4 Release Date

    I want to know the release date of JDK1.4.0. Where can I find this information.

  • External compositing tag in after effects cc

    I can't get an external compositing tag made in cinema 4D R15 to work correctly in AE CC via Cineware. In cinema 4D I have an asteroid following a spline from 0 to 100% and I need the keyframes for position in order to attach  at the 3D null Trapcode

  • Export Records from CRM 2011 to Sharepoint 2013

    We currently have CRM 2011 and are about to install Sharepoint 2013. We are wondering is it possible to export records from Entities in CRM 2011 to a folder in Sharepoint 2013? If this is possible can it be automated to run on a schedule? Any help on

  • SQL statement from ST05

    Hi All, Please let me know how to retrieve the SQL statement from ST05 output or how to know what is the field browsed and what was the input in SE16 from ST05. Thank you. With Regards, Gandhi Subramani