I have a name(the country) and a capital column inside my world table. I want to show only the name and capital that have the same number of characters. Like Greece and Athens that both equal 6 characters. I'm trying to use the LENGTH function, but unsure of what I'm doing wrong.
SELECT name, capital FROM world WHERE LEN(name) = LEN(capital);
CodePudding user response:
- There is a redundant
,
betweencapital
andFROM
. - In SQL you use
=
to compare, and not==
. - Looks like the site that you provided supports
LEN
function in order to get the length of a string.
SELECT name, capital FROM world WHERE LEN(name) = LEN(capital);
CodePudding user response:
You should not put comma(,) in front of "FROM" clause and you should use one equal to "=".
This should works -
SELECT name, capital FROM world WHERE LENGTH(name) = LENGTH(capital);