logo

该视频仅会员有权观看

立即开通课程「Node 框架 Express 实践」权限。

¥
199
/ 年

找出某个内容与这个内容的标签

  • To query content with ID 3 and its associated tags, the query conditions need to be adjusted to specify post id = 3.
  • Initially, there was only one tag associated with the content; however, a manual record can be added in the post tag to associate it with a new tag (ID 2).
  • After re-running the query, content ID 3 now has two tags. The issue of duplicate results was resolved by using GROUP BY post id and creating a JSON array called tax, which eliminates the tag name field and includes tag id and tag name within a JSON object.
  • For content with ID 1, which has no tags, the tax array returns a 'no'. A conditional IF was used to check the tag id; if there is no value, it outputs 'no'; otherwise, it displays the JSON object.
  • The new query results in a tax column that shows 'no' for content with no associated tags or a list of tags for content with tags.