Home  >  Article  >  Backend Development  >  sql语句(有点难,求高手)

sql语句(有点难,求高手)

WBOY
WBOYOriginal
2016-06-13 12:36:46780browse

求一个sql语句(有点难,求高手)

本帖最后由 dz215136304 于 2013-07-28 11:58:31 编辑 表
id pid title
1   0   标题1
2   0   标题2
3   2   标题3
4   2   标题4
5   2   标题5
6   5   标题6

需求 将表里的数据都查出来 并且如果pid等于别的数据id的话 id那条数据自动生成个字段,字段的数据是pid连接起来的且通过,分割 ,效果如下

id pid title   pidss
1   0   标题1  
2   0   标题2  3,4,5
3   2   标题3
4   2   标题4
5   2   标题5  6
6   5   标题6
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn