【发布时间】:2018-01-09 16:49:55
【问题描述】:
我有 2 个表格,“pages”和“custom_fields”。
页面
--------------------------------------------------
| id | title |
--------------------------------------------------
| 1 | about |
--------------------------------------------------
custom_fields
--------------------------------------------------
| id | page | field | output
--------------------------------------------------
| 1 | 1 | color | red
--------------------------------------------------
| 2 | 1 | shape | square
我想将“pages”中的 1 行与“custom_fields”中的所有相关行连接起来。但如果我使用简单的连接,它只会给我其中一个。我想做一个更智能的连接,使查询像这样
加入后的页面
--------------------------------------------------
| id | title | color | shape
--------------------------------------------------
| 1 | about | red | square
--------------------------------------------------
有什么想法吗?
【问题讨论】:
-
请提供您的查询。简单的 JOIN 应该足以获得您显示的结果。