Skip to content

Instantly share code, notes, and snippets.

@ashga
Created September 15, 2012 08:39
Show Gist options
  • Save ashga/3727013 to your computer and use it in GitHub Desktop.
Save ashga/3727013 to your computer and use it in GitHub Desktop.
generated sql query for spree
SELECT DISTINCT `spree_products`.* FROM `spree_products` INNER JOIN `spree_variants` ON
`spree_variants`.`product_id` = `spree_products`.`id` AND `spree_variants`.deleted_at IS NULL AND
`spree_variants`.is_master = 1 INNER JOIN `spree_products_taxons` ON
`spree_products_taxons`.`product_id` = `spree_products`.`id` INNER JOIN `spree_taxons` ON
`spree_taxons`.`id` = `spree_products_taxons`.`taxon_id` INNER JOIN `spree_product_properties` ON
`spree_product_properties`.`product_id` = `spree_products`.`id` WHERE `spree_products`.`deleted_at` IS
NULL AND `spree_taxons`.`id` IN (307170557) AND (available_on <= '2012-09-15 08:27:25') AND (
spree_variants.price >= 500.00 AND spree_products.id IN (SELECT spree_product_properties.product_id
FROM spree_product_properties where spree_product_properties.property_id = 33113319 AND
spree_product_properties.value = 'Acer' OR spree_product_properties.value = 'HP' ) AND
spree_products.count_on_hand > 0 AND spree_products.id IN (SELECT spree_product_properties.product_id
FROM spree_product_properties where spree_product_properties.property_id = 331867 AND
spree_product_properties.value = '4 GB' OR spree_product_properties.value = '8 GB' ) AND
spree_products.count_on_hand > 0 AND spree_products.id IN (SELECT spree_product_properties.product_id
FROM spree_product_properties where spree_product_properties.property_id = 3312374 AND
spree_product_properties.value = 'Core i3' OR spree_product_properties.value = 'Core i5' OR
spree_product_properties.value = 'Core i7' ) AND spree_products.count_on_hand > 0) ORDER BY
spree_variants.price asc LIMIT 25 OFFSET 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment