DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 10

Thread: Underscore problem

  1. #1
    Join Date
    Apr 2001
    Posts
    60
    Hi

    I have inserted some data starting with _(underscore). I would like to query the column to get the only the underscore rows. Can any one help me?
    rammi

  2. #2
    Join Date
    Apr 2001
    Posts
    107
    select column_name from your_table
    where column_name like '_%';

    Hope it helps

    Cheers

    Fabien

  3. #3
    Join Date
    Apr 2001
    Posts
    60
    Hi
    Thanks for the reply. But that doesnt work. It fetches all the rows. Any other solutions?
    rammi

  4. #4
    Join Date
    Jun 2001
    Location
    Helsinki. Finland
    Posts
    3,938
    Originally posted by ramya_ram
    Hi
    Thanks for the reply. But that doesnt work. It fetches all the rows. Any other solutions?
    This is a solution, not a suggestion :-)

    Code:
    select column_name from your_table
    where substr(column_name,1,1) = '_';

  5. #5
    Join Date
    Feb 2001
    Posts
    389
    select column_name from your_table
    where column_name like '\ _\%' ESCAPE '\' ;

  6. #6
    Join Date
    Apr 2001
    Posts
    60
    Hi
    The substr option is working fine. But I wanted to know the other query which I tried and getting no rows. I have given the results below for your reference.

    1 select type from type_designation_tab
    2* where substr(type,1,1)='_'

    TYPE
    ------------------------------
    _IBMNETFINITY4500R
    _NETFINITY5600
    _DELLPWREDG1300
    _NETVISTACELERON
    _IBM-PIII

    SQL> select type from type_designation_tab
    2 where type like '\_\%' ESCAPE '\';

    no rows selected

    SQL>
    rammi

  7. #7
    Join Date
    Mar 2002
    Posts
    171
    Ramya, try this:

    select type from type_designation_tab
    where type LIKE '%^_%' ESCAPE '^';

    This shd work.

  8. #8
    Join Date
    Jul 2000
    Location
    india
    Posts
    213
    Hi,

    Why u require a % before the _(underscore) when the requirement is the rows starting from _(underscore)..
    i think the query should be

    select type from type_designation_tab
    where type LIKE '^_%' ESCAPE '^';

    Hope i am right..

    thanks pras

  9. #9
    Join Date
    Apr 2001
    Posts
    60
    Hi
    Thanks a lot. It is working fine.
    rammi

  10. #10
    Join Date
    Mar 2002
    Posts
    171
    You are right Pras. I was just putting forth the syntax, didn't observe the specific.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width