我试图查询一组列表中的列表,这些建筑物与标签链接。我能够做到这一点,但我的问题是如何限制的标签的数量看:为每个选择一个元素和5个标签的列表
table buildings
id building_name style
1 Pompidou bla
2 Alcatraz bla
3 etc. etc.
table tags // they can be 50 or more per building
id tag_name
1 minimal
2 gothic
3 classical
4 modern
5 etc.
table buildings_tags
id building_id tag_id
我虽然做这样的事情来检索列表,但这不是compplete:
SELECT DISTINCT(tag), bulding_name
FROM buldings
INNER JOIN buildings_tags
ON buildings.id = buildings_tags.building_id
INNER JOIN tags
ON tags.id = buildings_tags.tag_id
LIMIT 0, 20
// result
building tag
Pompidou great
Pompidou france
Pompidou paris
Pompidou industrial
Pompidou renzo piano <= How to stop at the 5th result?
Pompidou hi-tech
Pompidou famous place
Pompidou wtf
etc.. etc...
此查询加载建筑物,但是此查询加载为建筑物链接的所有标记,而不仅仅是其中的5个?
你有没有尝试任何疑问? – Patrick 2010-03-12 18:07:26
还没有,我会尽快做,谢谢你的帮助! – vitto 2010-03-13 10:35:11