How to run a left join query on postmeta table?
-
Hello, I’m dying for a tip, please help!
I want to run a query on postmeta table and get 3 custom field value for each post. but my code got the post_id only.$query = <<<QUERY SELECT project_id.post_id FROM $wpdb->postmeta project_id LEFT JOIN $wpdb->postmeta height on height.post_id = project_id.post_id and height.meta_key = 'height' LEFT JOIN $wpdb->postmeta width on width.post_id = project_id.post_id and width.meta_key = 'width' WHERE project_id.meta_key = 'project_id' ORDER BY project_id.meta_value+(0) ASC QUERY;
If I remove the LEFT JOIN, the code still get the post_id. So, obviously my left join is wrong. Please help!
Viewing 13 replies - 1 through 13 (of 13 total)
Viewing 13 replies - 1 through 13 (of 13 total)
- The topic ‘How to run a left join query on postmeta table?’ is closed to new replies.