View previous topic :: View next topic
|
Author |
Message |
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
HI
I want to fetch the rows from the table where length of the data in one column should be 36 do have any operator to find the lenth of the data in the column
quer is some thing like this
select column1,column2
from table
where (i want to check lenth of data in column2 =36)
i want to RUN it in SPUFI plz help me |
|
Back to top |
|
|
rag swain
New User
Joined: 17 Dec 2007 Posts: 33 Location: pune,INDIA
|
|
|
|
You can use the LENGTH function in the where clause in your query, but then need to consider if the culumn is delared as NULL, VARCHAR or FIXED etc. If you post those decalration,someone here would have a pointer towards a more aprropriate solution.
[/code] |
|
Back to top |
|
|
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
Hi
The column data type is CHAR and it is NOT NULL |
|
Back to top |
|
|
abhishekmdwivedi
New User
Joined: 22 Aug 2006 Posts: 95 Location: india
|
|
|
|
Here's an example :
Code: |
Select col1,col2 from table where length(col2)=36; |
|
|
Back to top |
|
|
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
Hi
But inSPUFI i am getting all the rows in which col2 data length is not 36
my query is
SELECT SB_SRVC_DES
FROM GIBIT02.GIB_PRFR_LIST
WHERE LENGTH(SB_SRVC_DES) = 36;
plase clerify it |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
try STRIP... as
Code: |
WHERE LENGTH(STRIP(SB_SRVC_DES)) = 36;
|
search for STRIP to see its parameters. |
|
Back to top |
|
|
rag swain
New User
Joined: 17 Dec 2007 Posts: 33 Location: pune,INDIA
|
|
|
|
,or, you can use
Code: |
WHERE (LENGTH(RTRIM(COL_NAME))) = 36;
|
|
|
Back to top |
|
|
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
thanks a lot it is working |
|
Back to top |
|
|
mosinjamadar
New User
Joined: 26 Sep 2007 Posts: 42 Location: pune
|
|
|
|
You can use the LENGTH function in the where clause in your query, but then need to consider if the culumn is delared as NULL, VARCHAR or FIXED etc.
can u plz tell me whay u asked above thing |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If the field is a CHAR it has a fixed length of 36, which is why you were getting all rows. If it is VARCHAR it can vary in length. If it allows NULL you may have issues when executing the LENGTH(column) when the row has a value of NULL. |
|
Back to top |
|
|
rag swain
New User
Joined: 17 Dec 2007 Posts: 33 Location: pune,INDIA
|
|
|
|
Thanks! Stodolas, you said it all what i intended to, actally i was compiling a reply but came accross yours at the same time. |
|
Back to top |
|
|
|