Query to fetch name with mixed case

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suvitha
    New Member
    • Nov 2008
    • 4

    Query to fetch name with mixed case

    Hi All,

    Can anyone of you send me a query to fetch only the name of the users who has name in mixed case (lower and upper case) .

    And query to fetch only name with upper case ?

    Thanks.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Can you post the query that you are working on.

    Comment

    • suvitha
      New Member
      • Nov 2008
      • 4

      #3
      Originally posted by debasisdas
      Can you post the query that you are working on.

      Hi,

      I hv not tried that one .....as i am not familiar with that .

      Can u help.

      Comment

      • suvitha
        New Member
        • Nov 2008
        • 4

        #4
        select * from tablename where regexp_like(nam e,'[A-Z]'); - I executed this query and got

        ERROR at line 1:ORA-00920: invalid relational operator

        Comment

        • suvitha
          New Member
          • Nov 2008
          • 4

          #5
          [IMG]Hello[/IMG]

          Found the query:

          select name from tablename where name != lower(name);


          Hope this will help others

          Comment

          • amitpatel66
            Recognized Expert Top Contributor
            • Mar 2007
            • 2358

            #6
            For Mixed Case and Upper Case fetch

            [code=oracle]

            select * from emp where
            LENGTH(REPLACE( TRANSLATE(name, 'abcdefghijklmn opqrstuvwxyz',' '),' ','')) > 0

            [/code]

            Comment

            • Pilgrim333
              New Member
              • Oct 2008
              • 127

              #7
              Originally posted by amitpatel66
              For Mixed Case and Upper Case fetch

              [code=oracle]

              select * from emp where
              LENGTH(REPLACE( TRANSLATE(name, 'abcdefghijklmn opqrstuvwxyz',' '),' ','')) > 0

              [/code]
              wouldn't it be easier to use

              Code:
              select * from emp
              where name != lower(name) --Only this line in case of mixed cases and upper cases
              and   name != upper(name) --add this line just to get mixed cases

              Comment

              • amitpatel66
                Recognized Expert Top Contributor
                • Mar 2007
                • 2358

                #8
                Its always better not to use != (inequality) sign with strings

                My solution that includes TRANSLATE,REPLA CE can be easily rewritten using Regular Expressions in 10g. I am using 9i in my office so provided that solution

                Comment

                • Pilgrim333
                  New Member
                  • Oct 2008
                  • 127

                  #9
                  Well, in this case, the inequality is the lesser evil. The translate and replace will have to go through each string from the start to the end, even if there are no occurances of the occurance to replace or translate. Using a combination of translate and replace will make the query a lot slower. The inequality will stop with the comparison as soon as it finds the first difference.

                  Pilgrim.

                  Comment

                  • amitpatel66
                    Recognized Expert Top Contributor
                    • Mar 2007
                    • 2358

                    #10
                    Its not becuase of performance that I am asking not to use inequality, its because it causes wrong results some times in real time scenarios

                    Comment

                    • Pilgrim333
                      New Member
                      • Oct 2008
                      • 127

                      #11
                      Ah ok, in some cases it can lead to wrong results indeed.

                      Pilgrim.

                      Comment

                      • Saii
                        Recognized Expert New Member
                        • Apr 2007
                        • 145

                        #12
                        Which Oracle version are you using? In 10g you can use regular expressions

                        Comment

                        Working...