SQL Select

Executed SQL
SELECT `main`.`value_id`, `main`.`value` AS `file`, `main`.`entity_id` AS `product_id`, `value`.`label`, `value`.`position`, `value`.`disabled`, `default_value`.`label` AS `label_default`, `default_value`.`position` AS `position_default`, `default_value`.`disabled` AS `disabled_default` FROM `catalog_product_entity_media_gallery` AS `main` LEFT JOIN `catalog_product_entity_media_gallery_value` AS `value` ON main.value_id = value.value_id AND value.store_id = 1 LEFT JOIN `catalog_product_entity_media_gallery_value` AS `default_value` ON main.value_id = default_value.value_id AND default_value.store_id = 0 WHERE (main.attribute_id = '88') AND (main.entity_id in ('504')) ORDER BY IF(value.position IS NULL, default_value.position, value.position) ASC
value_id file product_id label position disabled label_default position_default disabled_default
990 /Q/J/QJY150171-L.jpg 504 AGATE • BOX I 1 0
992 /Q/J/QJY150171-L_1.jpg 504 QUARTZ • BOX I 2 0