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

Thread: returning value from column having ampersand

  1. #1
    Join Date
    Sep 2000
    Posts
    5
    In a table such as:

    COMPANY CONTACT
    --------- ---------
    M & M Mickey
    Jill & Co. Kate
    D & G Thandi
    XY and Z Alpheus


    How do I return only the contacts
    who work for companies with an '&'
    in their names?


    success?
    ntokozo

  2. #2
    Join Date
    Oct 2000
    Posts
    9

    Uses the ASCII value

    Hello,

    This should do the trick

    select contact
    from tablename
    where company like '%'||chr(38)||'%';

    Kind regards,

    SLAM

  3. #3
    Join Date
    Sep 2000
    Posts
    5

    Slammin'!

    Great idea. It worked perfectly!

    I also had suggestions to use 'set define off'
    in sqlplus. Replacing with ascii equiv. would
    avoid setting up the DBI to execute commands.

    Just how would I do that? (is it easy to do?)

    success?
    ntokozo

  4. #4
    Join Date
    Jan 2001
    Posts
    28
    You can do the following if you don't want to use the ascii values.

    SQL> set scan off
    SQL> select contact from tablename
    where company like '%&%';
    .
    .
    .

    SQL> set scan on

    Remember to set the scan back to on, as if you are trying to accept values using the & and if the scan is off, the value won't be prompted for.
    - Mayur.

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