Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    9

    Unanswered: Usage of BETWEEN Operator

    Hi,

    I came accross foll. question in one of my oracle reference book:

    Qn. How many rows will the foll. query return?
    Select * from emp where ename between 'A' AND 'C';

    Ans. 3 ALLEN, ADAMS & BLAKE.

    My doubt is why 'CLARK' is not included in the answer list?

    Any explanation to the above is be highly appreciated.

    Thanks & Regards,
    Rakesh.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    when comparing two strings of unequal length, the shorter is extended by appending blanks

    Code:
    'CLARK' is greater than 'C    '
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    This is because ALLEN is greater than 'A' as is anything starting with A having more than one character. Mr A would not occur in the output. By the same token CLARKE is greater than 'C' so cannot be between 'A' and 'C'.

    With BETWEEN 'A' AND 'C' you will output everthing from 'Aa...' to 'Bz...'.

Posting Permissions

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