在sql列中找到句子中超过10个字符的单词?

时间:2018-09-13 17:43:18

标签: mysql sql

如何在SQL列中找到最长的单词?例如,单词长于10个字符?

TITLE列的斜体字至少包含10个字符;

  • 非均质碳纤维纤维混凝土
  • 泊松回归模型
  • 意外射击
  • 过度训练在游泳中
  • 合成气中敏捷化学中的
  • 要求

2 个答案:

答案 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