Below is my database table structure in MySQL – I want to match specific dynamic field values with each other as described below:
meta_id post_id meta_key meta_value
616 472 "machine_type" "Combined pipe cutting"
561 472 _edit_lock 1354882015:1
560 472 _edit_last 1
562 472 _mf_write_panel_id 1
565 472 _wp_page_template machine_layout.php
617 472 jet_filter
618 472 "length_x_axis" "3000mm"
619 472 machine_image 488
Above I have "" quote marked the fields – against which I have to apply the query and fetch result.
Now here, I want to check meta_key field and meta_value field and want to retrieve the matching post_id field’s value.
For ex: my first parameter on meta_key will be length_x_axis and its matching value in meta_value will be 3000mm and AND condition with it will be meta_key for machine_type and its matching value in meta_value will be Combined pipe cutting.
And the result I need is post_id value 472
This is a complete dynamic wordpress wp_postmeta table which will have many records with conditions like this.
Earliest MySQL Query in result will be appreciated.
Please forgive me if any spell mistakes, I have tried my best to explain the community my question.
Please help !
I’m not sure what you really want, but i think that is the query you are looking for: