Take the 2-minute tour ×

I am reading contents of a file and adding it as a row in mysql db. The column in which the file contens will be added is a TEXT column.

There are multiple files that will be uploaded and it's contents are extracted in a cronjob and added to the TEXT column. One row per file.

My files sometimes are empty. In that case, a row with no content is created.

Now, I need to retrieve this content in another cronjob and perform some activities. I would like to filter and retrieve only those rows where content exists. Like using where clause with LENGTH(TRIM(ContentCol)) > 0. Since it is a TEXT column, I am unable to use LENGTH & TRIM functions.

Also when I use LENGTH function, it show different length.. I could see 5, 1 etc. though there is no value in the row-cell.

How can I perform this criteria?

share|improve this question
LENGTH(TRIM(t)) should work fine, perhaps there are whitespace characters in your text field that aren't being removed by trim. –  Ben English Nov 15 '11 at 21:01
add comment

1 Answer

up vote 0 down vote accepted

Well I use the function BIT_LENGTH(string); but only with short text data.

This function only return the length of bits, I evaluate this like

BIT_LENGTH(string) > 0
share|improve this answer
add comment

Your Answer


