Last active
August 29, 2015 14:03
-
-
Save Altreus/2b4e34ffbeeb2c9cb628 to your computer and use it in GitHub Desktop.
wat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM products | |
WHERE productId IN ( | |
SELECT relatedId | |
FROM product_suggestions | |
WHERE productId=? | |
) | |
AND live=1 | |
AND archive=0 | |
AND ( | |
countryId=? | |
OR ( | |
countryId=? | |
AND productId NOT IN ( | |
SELECT productId | |
FROM products | |
WHERE productId IN ( | |
SELECT relatedId | |
FROM product_suggestions | |
WHERE productId=? | |
) | |
AND countryId=? | |
) | |
) | |
) | |
AND productId IN ( | |
SELECT productId | |
FROM product_colours | |
WHERE productColourId IN ( | |
SELECT productColourId | |
FROM price_list_items | |
WHERE priceListId=? | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM products p | |
JOIN product_suggestions sug | |
ON sug.relatedId = p.productId | |
AND sug.productID = ? | |
JOIN product_colours col | |
ON col.productId = p.productId | |
JOIN price_list_items prices | |
ON col.productColourId = prices.productColourId | |
AND prices.priceListId = ? | |
WHERE p.live = 1 | |
AND p.archive = 0 | |
AND ( p.countryId = ? | |
OR p.countryId = ? ) | |
GROUP BY p.productId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment