I think that’s a pretty big ask. Not to mention we don’t know how many custom fields you have or what they’re called!
If I were you, I’d look at the wp_query
I’d ensure you query the correct post type and I’d look the OR operator, like this example:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'color',
'value' => 'blue',
'compare' => 'NOT LIKE',
),
array(
'key' => 'price',
'value' => array( 20, 100 ),
'type' => 'numeric',
'compare' => 'BETWEEN',
),
),
);
$query = new WP_Query( $args );
Once you’ve added ALL of your possible custom fields and the output displays something, you could look to output your wp_query in SQL using:
$customPosts = new WP_Query($yourArgs);
echo "Last SQL-Query: {$customPosts->request}";
That hopefully will give you the SQL you need.