Selecting rows containg a string of specified value length

by rajesh 2009-10-31 13:36:33

Lets consider a employee table with name as a column in it.

If we need to select and see only employees with name have five letters we can use wither of the following option

Using LENGTH function:

select * from employees where LENGTH(name) = 5;


Using Regular Expression:

select * from employees where name like '______';

In the above query we have used 5 "_" (underscores).
Each underscore points to one character

Tagged in:

1036
like
0
dislike
0
mail
flag

You must LOGIN to add comments