String Length in SQL

Level 123 keystrokes

LENGTH returns the length of a string; 'Hello' has 5 characters.

SQL code

-- LENGTH returns the length of the string: 5 for 'Hello'
-- In MySQL it counts bytes; use CHAR_LENGTH to count characters in non-ASCII text
1SELECT LENGTH('Hello');

Output

+-----------------+
| LENGTH('Hello') |
+-----------------+
|               5 |
+-----------------+
1 row in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • '× 2
  • ;× 1
  • (× 1
  • )× 1

More SQL examples at level 1

← SQL typing practice