2
I came across a problem:
1066 - Not Unique table/alias: 'catalog_product_entity_decimal'
SELECT DISTINCT catalog_product_entity.entity_id, sku, price as preco, qty as quantidade, stock_status as estoque, catalog_product_entity_decimal.value as embutido_regra_promo, catalog_product_entity_decimal.value as embutido FROM catalog_product_entity
INNER JOIN cataloginventory_stock_status ON (cataloginventory_stock_status.product_id = entity_id)
INNER JOIN catalog_product_index_price ON (catalog_product_index_price.entity_id = catalog_product_entity.entity_id)
INNER JOIN catalog_product_entity_decimal ON (catalog_product_entity_decimal.entity_id = catalog_product_entity.entity_id AND catalog_product_entity_decimal.attribute_id=249)
INNER JOIN catalog_product_entity_decimal ON (catalog_product_entity_decimal.entity_id = catalog_product_entity.entity_id AND catalog_product_entity_decimal.attribute_id=251)
The point is that the last two INNERS use the same table and column, but with different attributes in select, one set to bring the result of attribute_id 251 and the other 249.
Some solution?
RESOLUTION:
SELECT DISTINCT c0.entity_id, sku, price as preco, qty as quantidade, stock_status as estoque, c3.value as embutido_regra_promo, c4.value as embutido FROM catalog_product_entity c0 INNER JOIN cataloginventory_stock_status c1 ON (c1.product_id = c0.entity_id) INNER JOIN catalog_product_index_price c2 ON (c2.entity_id = c0.entity_id) INNER JOIN catalog_product_entity_decimal c3 ON (c3.entity_id = c0.entity_id AND c3.attribute_id=249) INNER JOIN catalog_product_entity_decimal c4 ON (c4.entity_id = c0.entity_id AND c4.attribute_id=251)
It worked, I just had to add the alias to the select part. Thank you, Emir.
– user2925795