Complete the code to find the length of the string 'Hello'.
SELECT [1]('Hello') AS length_value;
The LENGTH function returns the number of bytes in the string. It is commonly used to find string length in SQL.
Complete the code to find the number of characters in the string 'café'.
SELECT [1]('café') AS char_count;
CHAR_LENGTH returns the number of characters in a string, which is important for multibyte characters like 'é'.
Fix the error in the code to correctly get the character length of the string 'naïve'.
SELECT [1]('naïve') AS length;
CHAR_LENGTH correctly counts characters including multibyte ones like 'ï'. LENGTH counts bytes which can be misleading.
Fill both blanks to create a query that shows both byte length and character length of 'résumé'.
SELECT [1]('résumé') AS byte_length, [2]('résumé') AS char_length;
LENGTH returns the byte length, while CHAR_LENGTH returns the character count, useful for strings with multibyte characters.
Fill all three blanks to create a query that selects the string, its byte length, and its character length from a table named words.
SELECT word, [1](word) AS byte_len, [2](word) AS char_len FROM words WHERE [3](word) > 5;
The query selects each word, its byte length using LENGTH, its character length using CHAR_LENGTH, and filters words with byte length greater than 5.