Skip to content

Instantly share code, notes, and snippets.

@GeekOnCoffee
Created May 13, 2014 00:04
Show Gist options
  • Save GeekOnCoffee/02b97f63f4bd25bebfd5 to your computer and use it in GitHub Desktop.
Save GeekOnCoffee/02b97f63f4bd25bebfd5 to your computer and use it in GitHub Desktop.
SELECT "spree_variants".*
FROM "spree_variants"
LEFT OUTER JOIN "spree_option_values_variants" ON "spree_option_values_variants"."variant_id" = "spree_variants"."id"
LEFT OUTER JOIN "spree_option_values" ON "spree_option_values"."id" = "spree_option_values_variants"."option_value_id"
LEFT OUTER JOIN "spree_products" ON "spree_products"."id" = "spree_variants"."product_id"
AND "spree_products"."deleted_at" IS NULL
WHERE "spree_variants"."deleted_at" IS NULL
AND (((("spree_option_values"."name" LIKE '%Big%'
OR "spree_products"."name" LIKE '%Big%')
OR "spree_variants"."sku" LIKE '%Big%')
AND (("spree_option_values"."name" LIKE '%Red%'
OR "spree_products"."name" LIKE '%Red%')
OR "spree_variants"."sku" LIKE '%Red%')
AND (("spree_option_values"."name" LIKE '%Car%'
OR "spree_products"."name" LIKE '%Car%')
OR "spree_variants"."sku" LIKE '%Car%')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment