【发布时间】:2023-03-17 02:14:01
【问题描述】:
我有两张表,一张是“帖子”,另一张是“图片”
帖子表
标识 |文章 |
1 | post 1 |
2 | post 2 |
3 | post 3 |
图片表
项目 ID |图像名称|
1 | img1 |
1 | img2 |
2 | img3 |
2 | img4 |
3 | img5 |
3 | img6 |
我目前的查询是这样的:
SELECT * FROM `images` RIGHT JOIN `posts` ON images.project_id = posts.id
但它显示了帖子表中的多个结果。
我想要这样的结果,以避免出现多个结果。
post 1 - img1
post 2 - img3
post 3 - img5
【问题讨论】:
-
请显示您当前的结果。
-
告诉我查询给你的答案。我想它会给你: 1-post 1 -1-img1 //1-post 1 -1-img2//2-post 2 -2-img3//2-post 2 -2-img4 //3-post 3 -3-img5 //3-post 3 -3-img6