当我自己尝试时,我有一个有效的查询-
SELECT * FROM catalog_product_entity LEFT JOIN catalog_product_entity_decimal ON
catalog_product_entity_decimal.entity_id = catalog_product_entity.`entity_id` AND
catalog_product_entity_decimal.`attribute_id` = 64 AND catalog_product_entity_decimal.store_id = 2
AND catalog_product_entity.`entity_id` = catalog_product_entity_decimal.`entity_id`
但是 - 当我在更大的查询中运行它时 - 查询永远不会回来。
注意:当我删除这个加入时,查询工作得很好。
注意:我不想优化这个查询或任何东西,我只是想让这个表连接工作,以便我可以在结果集中使用它。
我称别名trickprice为不起作用的部分。
谁能帮我弄清楚为什么我的查询不起作用?
实际更大的查询:
SELECT DISTINCT
pe.entity_id AS ID,
prodname.value AS NAME,
pe.type_id AS TYPE,
eas.attribute_set_name AS AttribSetName,
pe.SKU,
Prodprice.value AS Price,
si.qty AS Quantity,
decimal_weight.value AS Weight,
special_shipping_group.value AS ShipGroup,
shipping_price.value AS ShipPrice,
ship_separately.value AS Separately,
ship_dimensional.value AS Dimensional,
black_friday_dropship.value AS BlackFridayDropship,
pvisibility.value AS Visibility,
CASE pstatus.value
WHEN 1 THEN 'Enabled'
WHEN 2 THEN 'Disabled'
ELSE NULL
END AS STATUS,
sites.web_sites AS Websites,
adlinfo_weight.value AS Product_weight,
adlinfo_length.value AS LENGTH,
adlinfo_width.value AS Width,
adlinfo_height.value AS Height,
adlinfo_diameter.value AS Diameter,
adlinfo_footprint.value AS Footprint,
adlinfo_material.value AS Material_Type,
adlinfo_steel.value AS steel_Notes,
adlinfo_upholstery.value AS upholstery,
adlinfo_foam.value AS Foam_Type,
adlinfo_details.value AS Other_Product_Specs,
jumprope_handle_length.value AS Handle_Length,
jumprope_handle_diameter.value AS Handle_Diameter,
jumprope_construction.value AS Handle_Mechanism,
jumprope_cable_type.value AS Cable_Type,
jumprope_cable_length.value AS Cable_Length,
jumprope_cable_diameter.value AS Cable_Diameter,
jumprope_cable_weight.value AS Cable_Weight,
CASE made_in_usa.value
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS MadeinUSA,
CASE free_shipping.value
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS FreeShipping,
CASE free_3.value
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS 3ShipsFree,
CASE patent_pending.value
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS PatentPending,
CASE econ_product.value
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS EconProduct,
specialty_crossfit.value AS Crossfit,
specialty_powerlift.value AS PowerLifting,
specialty_olympic.value AS OlympicLifting,
specialty_gymnastics.value AS Gymnastics,
CASE si.manage_stock
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS ManageStock,
'' AS Qtyfor_ItemsStatus_to_becomeOutofStock,
CASE si.is_in_stock
WHEN 1 THEN 'Yes'
WHEN 0 THEN 'No'
ELSE NULL
END AS StockAvailability ,
Pcategory.Mcategory AS MainCategory,
Ccategory.Scategory AS SubCategory
FROM catalog_product_entity AS pe
**LEFT JOIN catalog_product_entity_decimal AS trickprice ON trickprice.`entity_id` =2 AND trickprice.`attribute_id`=64 AND trickprice.`store_id` = 2**
JOIN cataloginventory_stock_item si ON pe.entity_id = si.product_id
JOIN eav_attribute_set eas ON eas.attribute_set_id = pe.attribute_set_id
JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 60 AND pe_varchar.store_id= 0) prodname ON pe.entity_id = prodname.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 258 AND pe_varchar.store_id= 0) adlinfo_weight ON pe.entity_id = adlinfo_weight.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 259 AND pe_varchar.store_id= 0) adlinfo_length ON pe.entity_id = adlinfo_length.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 260 AND pe_varchar.store_id= 0) adlinfo_width ON pe.entity_id = adlinfo_width.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 261 AND pe_varchar.store_id= 0) adlinfo_height ON pe.entity_id = adlinfo_height.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 262 AND pe_varchar.store_id= 0) adlinfo_diameter ON pe.entity_id = adlinfo_diameter.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 263 AND pe_varchar.store_id= 0) adlinfo_footprint ON pe.entity_id = adlinfo_footprint.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 264 AND pe_varchar.store_id= 0) adlinfo_material ON pe.entity_id = adlinfo_material.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 265 AND pe_varchar.store_id= 0) adlinfo_steel ON pe.entity_id = adlinfo_steel.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 266 AND pe_varchar.store_id= 0) adlinfo_upholstery ON pe.entity_id = adlinfo_upholstery.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 267 AND pe_varchar.store_id= 0) adlinfo_foam ON pe.entity_id = adlinfo_foam.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 323 AND pe_varchar.store_id= 0) jumprope_handle_length ON pe.entity_id = jumprope_handle_length.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 324 AND pe_varchar.store_id= 0 ) jumprope_handle_diameter ON pe.entity_id = jumprope_handle_diameter.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 329 AND pe_varchar.store_id= 0 ) jumprope_construction ON pe.entity_id = jumprope_construction.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 327 AND pe_varchar.store_id= 0 ) jumprope_cable_type ON pe.entity_id = jumprope_cable_type.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 325 AND pe_varchar.store_id= 0) jumprope_cable_length ON pe.entity_id = jumprope_cable_length.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 326 AND pe_varchar.store_id= 0 ) jumprope_cable_diameter ON pe.entity_id = jumprope_cable_diameter.entity_id
LEFT JOIN
(SELECT pe_varchar.entity_id,pe_varchar.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_varchar AS pe_varchar ON pe_varchar.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 328 AND pe_varchar.store_id= 0) jumprope_cable_weight ON pe.entity_id = jumprope_cable_weight.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 84 AND pe_int.store_id= 0) pstatus ON pe.entity_id = pstatus.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,oval.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
LEFT JOIN eav_attribute_option_value oval ON pe_int.value = oval.option_id
WHERE ea.attribute_id = 155 AND pe_int.store_id= 0) special_shipping_group ON pe.entity_id = special_shipping_group.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 89 AND pe_int.store_id= 0) pvisibility ON pe.entity_id = pvisibility.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 344 AND pe_int.store_id= 0) black_friday_dropship ON pe.entity_id = black_friday_dropship.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 169 AND pe_int.store_id= 0) ship_separately ON pe.entity_id = ship_separately.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 170 AND pe_int.store_id= 0) ship_dimensional ON pe.entity_id = ship_dimensional.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 149 AND pe_int.store_id= 0) made_in_usa ON pe.entity_id = made_in_usa.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 150 AND pe_int.store_id= 0) free_shipping ON pe.entity_id = free_shipping.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 255 AND pe_int.store_id= 0) free_3 ON pe.entity_id = free_3.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 284 AND pe_int.store_id= 0) patent_pending ON pe.entity_id = patent_pending.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,pe_int.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 337 AND pe_int.store_id= 0) econ_product ON pe.entity_id = econ_product.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,oval2.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
LEFT JOIN eav_attribute_option_value oval2 ON pe_int.value = oval2.option_id
WHERE ea.attribute_id = 238 AND pe_int.store_id= 0) specialty_crossfit ON pe.entity_id = specialty_crossfit.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,oval3.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
LEFT JOIN eav_attribute_option_value oval3 ON pe_int.value = oval3.option_id
WHERE ea.attribute_id = 241 AND pe_int.store_id=0) specialty_powerlift ON pe.entity_id = specialty_powerlift.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,oval4.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
LEFT JOIN eav_attribute_option_value oval4 ON pe_int.value = oval4.option_id
WHERE ea.attribute_id = 240 AND pe_int.store_id= 0) specialty_olympic ON pe.entity_id = specialty_olympic.entity_id
LEFT JOIN
(SELECT pe_int.entity_id,oval5.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_int AS pe_int ON pe_int.attribute_id = ea.attribute_id
LEFT JOIN eav_attribute_option_value oval5 ON pe_int.value = oval5.option_id
WHERE ea.attribute_id = 239 AND pe_int.store_id= 0) specialty_gymnastics ON pe.entity_id = specialty_gymnastics.entity_id
LEFT JOIN
(SELECT pe_decimal.entity_id,pe_decimal.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_decimal AS pe_decimal ON pe_decimal.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 64 AND pe_decimal.store_id= 0) Prodprice ON pe.entity_id = Prodprice.entity_id
LEFT JOIN
(SELECT pe_decimal.entity_id,pe_decimal.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_decimal AS pe_decimal ON pe_decimal.attribute_id = ea.attribute_id AND ea.entity_type_id = pe_decimal.entity_type_id
WHERE ea.attribute_id = 216 AND pe_decimal.store_id= 0) shipping_price ON pe.entity_id = shipping_price.entity_id
LEFT JOIN
(SELECT pe_decimal.entity_id,pe_decimal.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_decimal AS pe_decimal ON pe_decimal.attribute_id = ea.attribute_id AND ea.entity_type_id = pe_decimal.entity_type_id
WHERE ea.attribute_id = 69 AND pe_decimal.store_id= 0) decimal_weight ON pe.entity_id = decimal_weight.entity_id
LEFT JOIN
(SELECT pe_text.entity_id,pe_text.value
FROM eav_attribute AS ea
LEFT JOIN catalog_product_entity_text AS pe_text ON pe_text.attribute_id = ea.attribute_id
WHERE ea.attribute_id = 268 AND pe_text.store_id= 0 ) adlinfo_details ON pe.entity_id = adlinfo_details.entity_id
LEFT JOIN
(SELECT ss.product_id,GROUP_CONCAT(web.name) AS web_sites
FROM cataloginventory_stock_status ss LEFT JOIN core_website web ON web.website_id = ss.website_id
GROUP BY ss.product_id) sites ON sites.product_id = pe.entity_id
LEFT JOIN
(
SELECT cp.product_id, GROUP_CONCAT(category.value) AS Mcategory
FROM catalog_category_entity_varchar category
JOIN catalog_category_entity p ON p.entity_id = category.entity_id
JOIN catalog_category_product cp ON cp.category_id = p.entity_id
WHERE category.attribute_id = 33 AND category.store_id = 0 AND p.parent_id=2
GROUP BY cp.product_id
) Pcategory ON pe.entity_id = Pcategory.product_id
LEFT JOIN
(
SELECT cp.product_id, GROUP_CONCAT(category.value) AS Scategory
FROM catalog_category_entity_varchar category
JOIN catalog_category_entity p ON p.entity_id = category.entity_id
JOIN catalog_category_product cp ON cp.category_id = p.entity_id
WHERE category.attribute_id = 33 AND category.store_id = 0 AND p.parent_id > 2
GROUP BY cp.product_id
) Ccategory ON pe.entity_id = Ccategory.product_id
WHERE pe.entity_id = 2
LIMIT 0,1