skip to Main Content

used BETWEEN optr with range ‘a’ and ‘z’.

i want to get all the name by using BETWEEN operator only
but as you can see BETWEEN optr only include lower_range(a) and not upper_range(z) , but i also want name starting from character ‘z’. can we get it??
note:we can only use BETWEEN optr.
You can look into the picture.

2

Answers


  1. As second argument of the BETWEEN, uses the next character after z which is chr(ascii(‘z’)+1) ("{") or use rpad(‘z’,length_of_name_column, ‘z’).

    Login or Signup to reply.
  2. if you can change also name column :

    select * from sample1 where substring(name, 1, 1) between 'a' AND 'z'
    

    if you have many records, using rpad my degrade performance

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search