How to display name starting from 'z' by using BETWEEN cmd only?

51 views Asked by At

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

There are 2 answers

2
p3consulting On

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').

2
tahzibi.jafar On

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