While joining it to wp_posts, how can I put all the values of wp_postmeta table in one row?

I want to join wp_posts and wp_postmeta table like this:

SELECT wp_posts.id, wp_posts.post_title, wp_posts.post_author, wp_postmeta.meta_key, wp_postmeta.meta_value
FROM wp_posts 
LEFT JOIN wp_postmeta ON wp_posts.id = wp_postmeta.post_id
WHERE post_type = 'job';

But I need the values of the key-value pairs in the wp_postmeta table to be in one row; so that the select statement looks something like this:

SELECT wp_posts.id, wp_posts.post_title, wp_posts.post_author, wp_postmeta.meta_key1, wp_postmeta.meta_key2, wp_postmeta.meta_key3, wp_postmeta.meta_key4

How can I modify by select statement to do so? Any help is appreciated.

Read more here: While joining it to wp_posts, how can I put all the values of wp_postmeta table in one row?

Leave a Reply

Your email address will not be published. Required fields are marked *