emma_soraya emma_soraya - 8 months ago 72
SQL Question

to_number from char sql

I have to select only the IDs which have only even digits (an ID looks like: p19 ,p20 etc). That is, p20 is good (both 2 and 0 are even digits); p18 is not.

I thought to use substr to get each number from the IDs and then see if it's even .

select from profs
where to_number(substr(id_prof,2,2))%2=0 and to_number(substr(id_prof,3,2))%2=0;


IF you need all rows consist of 'p' in beginning and even digits on tail It should look like:

select *
  from profs 
 where regexp_like (id_prof, '^p[24680]+$');