Hi please see my two table and data
/* wp_posts */
ID post_title post_type post_status
1 testproduct product publish
/* wp_postmeta */
meta_id post_id meta_key meta_value
1 1 _price 20
2 1 _regularprice 30
3 1 _stock_status instock
4 1 _qty 3
I need to fetch all data from these two table for getting every details of product . For that I write the following query, but it doesn't work, please help.
SELECT p.post_title,m.meta_key,m.meta_value FROM wp_posts p LEFT JOIN wp_postmeta m LEFT JOIN wp_post_meta m1 ON p.ID = m.post_id AND m.meta_key = '_price' AND m1.meta_key= '_regular_price' WHERE p.post_status = 'publish' AND p.post_type = 'product'