Answer the question
In order to leave comments, you need to log in
How to optimize SQL query using JOIN for same nested SELECT?
Help optimize query via JOIN for nested subqueries joined by UNION. I remember that this should be more logical and faster
SELECT
product_id,
min_price,
max_price,
82.23546 as rate
FROM
wp_wc_product_meta_lookup
WHERE
product_id IN (
SELECT
post_id
FROM
wp_postmeta
WHERE
meta_key = 'convert_to_rub'
AND meta_value = 1
)
UNION
SELECT
product_id,
min_price,
max_price,
1 as rate
FROM
wp_wc_product_meta_lookup
WHERE
product_id NOT IN (
SELECT
post_id
FROM
wp_postmeta
WHERE
meta_key = 'convert_to_rub'
AND meta_value = 1
)
GROUP BY
product_id
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question