Using the following query I have fetched results from wp_posts and wp_postmeta table.
SELECT a., b. FROM wp_posts a, wp_postmeta b WHERE a.ID = b.post_id AND a.post_status = 'publish' AND a.post_type='wpsc-product'
From the above result, I want to filter the results to one more stage
As you know wp_postmeta structure is like
meta_id | post_id | meta_key | meta_value
I want to make all the meta_key values of the result to column names and its corresponding value as its value.
For eg if the table is like:
Meta_id-----------post_id-----------meta_key-----------meta_value
1-----------------31--------------mk1----------------mv1
2-----------------31--------------mk2----------------mv2
3-----------------31--------------mk3----------------mv3
The expected result is:
Meta_id-----------post_id-----------mk1--------mk2---------mk3
1-----------------31-----------------mv1---------mv2---------mv3
Is this possible??? I want this along with my join query.
The formatting of question is not correct. Please forgive for that.