【发布时间】:2012-07-05 19:51:32
【问题描述】:
我想加入表格 Documents(id, name) 和 Tags(tagId, tagname, docId(FK))。但是结果会返回很多冗余行,因为一个文档可以有很多标签:
Document_name |Tag
----------------------
document01 tag01
document01 tag02
document02 tag01
我试图解决的只是:
document_name |Tags
----------------------------
document01 | tag01, tag02
document02 | tag01
或者可以是这样的:
Document_name |Tag_1 |Tag_2 |Tag_...
---------------------------------------
document01 tag01 |tag02
document02 tag01
有人知道如何实现这种情况吗?非常感谢! (我试图在这个网站上找到其他答案,但我不知道在这种情况下搜索合适的关键字)
【问题讨论】:
-
[这可能会有所帮助][1] 我特别喜欢带有 STUFF 子句 [1] 的那个:stackoverflow.com/questions/451415/…