The WordPress table wp_postmetahas all the extra fields for a post, but they are in rows, so they are easy to add.
However, now I want to request for all fields of all messages that, say, I obviously need these fields in a column, not a row.
This is my request that I run
SELECT p.post_title,
m.meta_value,
m.meta_key
FROM wp_posts p
JOIN wp_postmeta m
ON p.id = m.post_id
WHERE p.id = 72697;
This will give me all the meta values and their corresponding meta keys as columns. But I need meta-key values as columns and meta-values as rows
For example, meta_keymaybe additional_description, and this value can beWhat up
So I need something like this
SELECT p.post_title, additional_description
FROM wp_posts p
JOIN wp_postmeta m
ON p.id = m.post_id
WHERE p.id = 72697;
. , , , where, ( , ).
,
wp_postmetap >
meta_key post_id meta_key meta_value
1 5 total_related 5
2 5 updated 0
3 5 cricket 1
4 8 total_related 8
5 8 updated 1
6 8 cricket 0
wp_post table
id post_title other things I dont care about
5 This is awesome
8 This is more awesome
wp_post id post_id wp_postmetap >
post_title total_related updated cricket
This is awesome 5 0 1
This is more awesome 8 1 0