MySQL Limit with Many to Many Relationship

后端 未结 4 685
傲寒
傲寒 2021-02-06 18:43

Given a SCHEMA for implementing tags

ITEM ItemId, ItemContent

TAG TagId, TagName

ITEM_TAG ItemId, TagId

What is the best way to limit the number

4条回答
  •  猫巷女王i
    2021-02-06 19:20

    You could also use Distinct/Group By:

    SELECT DISTINCT TagID, TagName FROM ((TAG T INNER JOIN ITEM_TAG I_T ON T.TagID = I_T.TagID) INNER JOIN ITEM I ON I_T.ItemID = I.ItemID) GROUP BY TagID, TagName

提交回复
热议问题