如何在SQL列中找到最长的单词?例如,单词长于10个字符?
TITLE列的斜体字至少包含10个字符;
答案 0 :(得分:1)
您可以使用:
select length(t.col) as l_col, t.col
from
(
select 'Non-homogeneous Carbon Fiberconcrete' as col
union all
select 'Accidental Shot'
union all
select 'Overtraining in Swimming'
union all
select 'Requirements in Agile Chemical From Syngas'
) t
order by l_col desc
limit 1;
L_COL COL
----- ------------------------------------------
42 Requirements in Agile Chemical From Syngas
答案 1 :(得分:0)
这是我的SQL Server代码。
select c.name as col
from sys.columns c
join sys.tables t ON c.object_id = t.object_id
where t.name = 'your table name'
and len(c.name) > 10