直接用SQL语句拼接结果
如何将查询得到的数据拼接起来过去的办法是先把数据取过来然后循环结果进行数据拼接。现代数据库已经提供了这个功能只是各数据库语法不同。假设表person_template:person_Idtemplate_Id4147575T0014147575T0021、SQL Serverselect ,template_id from person_template where person_id4147575 for XML path ()返回,T001,T002可以用stuff函数去掉第一个逗号2、MySQLSELECT GROUP_CONCAT(template_Id) AS template_id FROM person_template WHERE person_Id 4147575;3、OracleSELECT LISTAGG(template_Id, ,) WITHIN GROUP (ORDER BY template_Id) AS template_id FROM person_template WHERE person_Id 4147575;