Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2004
    Posts
    35

    Unanswered: Pattern Matching (using Like)

    Hi, how can I do a match on multiple similar words..


    My select query is like this..

    select * from xxx a, yyy b where a.uuid_nbr = b.user_id and UPPER(a.company_nm)
    like ('FedEx%', 'FedEx Emp', 'Federal Express%', 'FedEx Emp', 'Fed Ex%',
    'FedEx Emp','fdx%','FedEx Emp', 'Non-FedEx Emp')


    Can anybody help me?

  2. #2
    Join Date
    Apr 2004
    Posts
    22

    Re: Pattern Matching (using Like)

    Originally posted by durbhakula
    Hi, how can I do a match on multiple similar words..


    My select query is like this..

    select * from xxx a, yyy b where a.uuid_nbr = b.user_id and UPPER(a.company_nm)
    like ('FedEx%', 'FedEx Emp', 'Federal Express%', 'FedEx Emp', 'Fed Ex%',
    'FedEx Emp','fdx%','FedEx Emp', 'Non-FedEx Emp')


    Can anybody help me?
    --------------

    I m not sure but.. could you try IN operator instead of LIKE ??

  3. #3
    Join Date
    Feb 2004
    Posts
    35
    I found a way..It's not sleek...But it works..Maybe someone could shed some light on this..

    select * from xxx a, yyy b where a.uuid_nbr = b.user_id and UPPER(a.company_nm)
    like 'FedEx%' and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Federal Express%'
    and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Fed Ex%'
    and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'fdx%' and
    UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Non-FedEx Emp'

    Does anybody know any better way of handling this??

  4. #4
    Join Date
    Oct 2003
    Posts
    71
    Shouldn't it be

    select * from xxx a, yyy b where a.uuid_nbr = b.user_id and
    (
    UPPER(a.company_nm)
    like 'FedEx%' OR UPPER(a.company_nm) like 'FedEx Emp' ORUPPER(a.company_nm) like 'Federal Express%'
    OR UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) OR 'Fed Ex%'
    and UPPER(a.company_nm) like 'FedEx Emp' OR UPPER(a.company_nm) like 'fdx%' OR
    UPPER(a.company_nm) like 'FedEx Emp' OR UPPER(a.company_nm) like 'Non-FedEx Emp'
    )


    Changed and to OR

    Originally posted by durbhakula
    I found a way..It's not sleek...But it works..Maybe someone could shed some light on this..

    select * from xxx a, yyy b where a.uuid_nbr = b.user_id and UPPER(a.company_nm)
    like 'FedEx%' and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Federal Express%'
    and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Fed Ex%'
    and UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'fdx%' and
    UPPER(a.company_nm) like 'FedEx Emp' and UPPER(a.company_nm) like 'Non-FedEx Emp'

    Does anybody know any better way of handling this??

  5. #5
    Join Date
    Dec 2003
    Posts
    1,074
    you'd also want to capitalize the string literal you're searching on:

    OR UPPER(a.company_nm) like 'FED EX%'

    and I think you can shorten things:

    UPPER(a.company_nm) like '%FED EX%' Or UPPER(a.company_nm) like '%FEDEX%' Or UPPER(a.company_nm) like '%FDX%' Or UPPER(a.company_nm) like 'FEDERAL EXPRESS%'

    -cf

  6. #6
    Join Date
    Feb 2004
    Posts
    35
    That's great folks..Thanks

    Reema, I did not see the 'AND' thing.. Good catch there..

Posting Permissions

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