# find promotion's products with promotion_id = 2 # if product ids result is 2,7 select product_id from spree_product_promotion_rules where promotion_rule_id=(select id from spree_promotion_rules where type='Spree::Promotion::Rules::Product' and promotion_id=2) # find the promotion product's quantity if order_id = 3 select distinct(spree_line_items.variant_id), spree_line_items.quantity from spree_product_promotion_rules left join spree_line_items on spree_product_promotion_rules.product_id = spree_line_items.variant_id where spree_product_promotion_rules.product_id in (2,7) and spree_line_items.order_id=3