1
我正在尝试查询posts that have all of the given tags
。如何同时获取与某些标签相关的帖子?
我对posts that have one of the given tags
的查询。
查询我的是:
select * from `blog_posts`
inner join `blog_post_tag` on `blog_posts`.`id` = `blog_post_tag`.`post_id`
where `blog_post_tag`.`tag_id` in (?, ?)
and `blog_posts`.`deleted_at` is null
例如:
| post_id | tag_id |
|---------+--------|
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 3 | 2 |
对于给定的标签
[1]
,结果应该给我的职位与IDS1
和2
。对于给定的标签
[1, 2]
,结果应该给我的职务与ID1
(不[1, 2, 3]
)。
@jpw谢谢,我想...... :) –
@jpw我已经做了... –