Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
DB2 SQL => 如何从字符串的一部分中获取长度?例如,该列的数据是
MARYqORANGE JENNYqBLUE, DAVEqYELLOW, JONATHANqGREEN AMANDAqBLACK
我怎样才能得到这些数据的长度q?
q
使用locate功能:
locate
select locate('q', col)
如果您想要“q”之前的初始部分,请使用:
select (case when col like '%q%' then left(col, locate('q', col) - 1) else col end)