filter only by one character

Hi ,
I have data as below

mary
john simpson
L
P
KAMRA

I want result like

L
P

Thanks
sam2929Asked:
Who is Participating?
 
Dave FordConnect With a Mentor Software Developer / Database AdministratorCommented:
So, are you trying to get only rows where the target column has only one character? ... or are you trying to get rows where the data in that column START with 'L' or 'P'?

 select someData                  
   from deleteMe            
  where length(trim(someData)) = 1

Open in new window


-- DaveSlash
1
 
Dave FordSoftware Developer / Database AdministratorCommented:
I'm not really clear. What, exactly, are you trying to accomplish?
0
 
awking00Commented:
For all columns with only one character -
select column from yourtable where length(column) = 1
For all columns starting with 'L' or 'P' -
select column from yourtable where substr(column,1,1) in ('L','P')
For all columns where the column value is 'L' or 'P'
select column from yourtable where length(column) = 1 and column in ('L','P')
0
 
awking00Commented:
If you're only looking for one-character values in your column, then the trim function is unnecessary.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.