if have a post,
id = 10
meta_key = size
meta_value = xxl
meta_key = color
meta_value = red
how can i get this post_id
with sql like this
$my_post_id = $wpdb->get_results($wpdb->prepare( " SELECT post_id FROM $wpdb->postmeta WHERE meta_value = 'xxl' "),'ARRAY_A');
Your base query for that would be
Here is SQLFiddle demo