sql stuff拼接字符串的用法
Posted 我的名称很霸气
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql stuff拼接字符串的用法相关的知识,希望对你有一定的参考价值。
要把图2显示成图1的方法:要用到stuff函数,并且图1显示的时间有所截断。
图2sql,只是很普通的sql
select * from Access_Statistics where SFZH=\'152923199608242120\' and CONVERT(varchar(100), SKSJ, 112)=\'20161015\' order by SKSJ
图1sql,用了stuff拼接
select dz.XM as 姓名,dz.JSZH as 卡号,[刷卡时间]=stuff((select \',\'+substring(CONVERT(varchar(100), SKSJ, 8),0,6) from Access_Statistics where SFZH=mj.SFZH and CONVERT(varchar(100),SKSJ, 112)=\'20161015\' and SFZH=\'152923199608242120\' order by SKSJ for xml path(\'\') ), 1, 1, \'\') from Access_Statistics mj inner join Readers dz on dz.SFZH = mj.SFZH inner join XX04 bj on dz.BJBH=bj.BJBH where CONVERT(varchar(100), mj.SKSJ, 112)=\'20161015\' and mj.SFZH=\'152923199608242120\' group by mj.SFZH,dz.XM,dz.JSZH
以上是关于sql stuff拼接字符串的用法的主要内容,如果未能解决你的问题,请参考以下文章