如何查找3列具有相同字符数的行?

时间:2021-11-11 04:36:34

A table contains name, city and country.

表格包含姓名,城市和国家/地区。

Now need a SQL query for showing the name, city and country where the name, city and country have the same number of characters

现在需要一个SQL查询来显示名称,城市和国家/地区的名称,城市和国家/地区的字符数相同

Thanks a ton!

万分感谢!

2 个解决方案

#1


0  

For Oracle, you can use Length():

对于Oracle,您可以使用Length():

SELECT * FROM Table1 WHERE Length(Column1) = Length(Column2) and Length(Column1) = Length(Column3)

You can read more about Length() on this page.

您可以在此页面上阅读有关Length()的更多信息。

#2


0  

Hoping, i understood correctly

希望,我理解正确

Please check below query

请检查以下查询

SELECT name, , city,  capital
FROM table WHERE
LENGTH(name) =  LENGTH(city)
and LENGTH(city) = LENGTH(capital);

#1


0  

For Oracle, you can use Length():

对于Oracle,您可以使用Length():

SELECT * FROM Table1 WHERE Length(Column1) = Length(Column2) and Length(Column1) = Length(Column3)

You can read more about Length() on this page.

您可以在此页面上阅读有关Length()的更多信息。

#2


0  

Hoping, i understood correctly

希望,我理解正确

Please check below query

请检查以下查询

SELECT name, , city,  capital
FROM table WHERE
LENGTH(name) =  LENGTH(city)
and LENGTH(city) = LENGTH(capital);