Mysql - Wordpress:列出具有多个元数据值的自定义帖子
在 WordPress 中,自定义帖子保存在 wp_posts
表中,其 ID 在另一个表 wp_meta
中引用,其中包含以下列 post_id、meta_key、meta_value
假设我在 wp_posts
中有一个名为 pudding
的食谱,在 wp_meta
中我有 3 个meta_keys: "time_for_preparation", "ingredients", "difficulty"
如何编写一个 mysql 查询,返回包含 3 个 meta_keys 的单行?
如果我进行内部联接,我只会看到 3 组“布丁”,每组都具有相同的 wp_posts
数据和一个不同的 meta_key
我想要的是单行 布丁
用一个meta_keys数组
可以做到吗?
In wordpress, custom posts are held in the wp_posts
table, and their ID is referenced in another table wp_meta
with the following columns post_id, meta_key, meta_value
Let's say I have a recipe called pudding
in wp_posts
, and in wp_meta
I have 3 meta_keys: "time_for_preparation", "ingredients", "difficulty"
How do I write a mysql query that returns me a single row with the 3 meta_keys?
If I do an inner join I'll just see 3 sets of "pudding", each with the same wp_posts
data and ONE different meta_key
What I want is a single row of pudding
with an array of meta_keys
can that be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这都是我在 MS SQL Server 中完成的
,将其更改为您可以看到这篇文章,其中有 MYSql how-do-i-create-a-comma-separated-list-using-a-sql-query
已编辑
正如我没有 mysql,但我尝试使用我建议你的 url 来转换它,所以我认为这将在 mysql 中,如下所示
this is all done by me in MS SQL Server
for changing this into you can see this post which have for MYSql how-do-i-create-a-comma-separated-list-using-a-sql-query
Edited
as i dont have mysql but i tried to convert this by using the url which i have suggested you so i think this will be in mysql like below