Last active
May 27, 2018 15:15
-
-
Save ateneva/905cffae481670a00e1a615db5eef72b to your computer and use it in GitHub Desktop.
How do I determine the length of a string with SQL?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------SQL Server--------------------------------------- | |
select | |
'I love you' as phrase, | |
len('I love you') as phrase_length, | |
len(' I love you ') as phrase_length2, | |
datalength(' I love you ') as phrase_length3 | |
phrase |phrase_length |phrase_length2 |phrase_length3 | | |
-----------|--------------|---------------|---------------| | |
I love you |10 |11 |12 | | |
--------------MySQL---------------------------------------------- | |
select | |
'I love you' as phrase, | |
length('I love you') as phrase_length | |
phrase |phrase_length | | |
-----------|--------------| | |
I love you |10 | | |
--------------PostgreSQL----------------------------------------- | |
select | |
'I love you' as phrase, | |
length('I love you') as phrase_length | |
phrase |phrase_length | |
-----------|-------------- | |
I love you |10 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment