我有以下查询。
select entity_id ,parent_id,name as label , url_key as name from magento_catalog_category_flat_store_1 where entity_id IN(select
distinct flat.parent_id from magento_catalog_category_flat_store_1 as flat RIGHT JOIN sohyper_region_activity as act on flat.entity_id = act.activity_id )
由于IN子句,上述查询会降低性能。谁能告诉我如何在这个查询中用JOIN替换IN子句?
感谢。
答案 0 :(得分:0)
SELECT m.entity_id ,m.parent_id,m.name as label , m.url_key as name
FROM magento_catalog_category_flat_store_1 as m
INNER JOIN magento_catalog_category_flat_store_1 as flat
ON m.entity_id = flat.parent_id
RIGHT JOIN sohyper_region_activity as act on flat.entity_id = act.activity_id
答案 1 :(得分:0)
是试试这个
SELECT T1.entity_id, T1.parent_id, T1.name As Label, T1.url_key As Name
FROM magento_catalog_category_flat_store_1 T1
INNER JOIN magento_catalog_category_flat_store_1 as T2 ON
T1.entity_id = T2.parent_id
RIGHT JOIN sohyper_region_activity as T3 on
T2.entity_id = T3.activity_id