【发布时间】:2020-04-18 21:51:11
【问题描述】:
如果我有 2 个类似的表,你会如何建议构建查询
表格'帖子'
ID | post_cat | post_type | post_date
1 | 1 | 0 | xyz
2 | 3 | 1 | xyz
表'post_meta'
p_id | meta_key | meta_value
1 | name | John
1 | location | NY
1 | age | 31
2 | name | Jane
2 | age | 26
要求:
1. 我想得到如下结果:
ID | post_cat | post_type | post_date | name | location | age
1 | 1 | 0 | xyz | john | NY | 31
2 | 3 | 1 | xyz | Jane | | 26
- 当我尝试根据 post_meta > meta_key 获取结果时,您建议如何进行查询;例如搜索帖子,其中 post_meta.meta_key=location 和 meta_value=NY?
【问题讨论】:
-
请告诉我们你的尝试。