https://blog.csdn.net/weixin_39703170/article/details/79651776
mysql:
1、使用left截取前10个字符(left比较好用,substring、substr容易出错)
SELECT left(testStr,10) FROM testTable
2、小于6位的全部展示,否则展示前六位加省略号
select
case when LENGTH(testStr) < 7 then testStr
else CONCAT(left(testStr,6),"...")
end testStr
from testTable
注意:如果是在mabatis中,<要用<来替代
concat(substr(bjnr,0,28),'...')
oracle:
(oracle不支持left?)
select
case when LENGTH(testStr) < 7 then testStr
else concat(substr(testStr,0,7),'...')
end testStr
from testTable