Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select one text column, which string length >0?

Tags:

mysql

Is there any function like "strlen" in mysql?

like image 980
lovespring Avatar asked Jul 01 '10 12:07

lovespring


People also ask

How do I select a specific length in SQL?

To query for string fields with a specific length, use the char_length() or length() from MySQL.

How do I query the length of a string in SQL?

LEN() function calculates the number of characters of an input string, excluding the trailing spaces. It is an expression that can be a constant, variable, or column of either character or binary data. Returns : It returns the number of characters of an input string, excluding the trailing spaces.

Can we use length function in where clause?

The answer is YES, you can use LEN like above.

How do I find the minimum length of a string in SQL?

(SELECT min(len(<string_column>)) FROM<table_name> ) ; Example : SELECT TOP 1 * FROM friends WHERE len(firstName) = (SELECT min(len(firstName)) FROM friends);


2 Answers

Mysql does have a length function to return the length of a string.

so you could do something like.

select * from some_table where length(some_string) > 0;
like image 115
Robby Pond Avatar answered Oct 10 '22 03:10

Robby Pond


You can do it with using LENGTH keyword

SELECT * FROM table WHERE LENGTH (name) > 150;
like image 44
onurbaysan Avatar answered Oct 10 '22 02:10

onurbaysan