Created
October 30, 2017 20:54
-
-
Save andku83/13bef3a094f929f097c2e75ba2e34da3 to your computer and use it in GitHub Desktop.
This file contains 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 | |
product.id AS id, | |
product.image AS image, | |
product_additional_val.count_color AS count_color, | |
product_additional_val.url AS url | |
FROM | |
product | |
INNER JOIN ( | |
SELECT | |
COUNT(product_additional.cid) AS count_color, | |
product_additional.* | |
FROM | |
product_color | |
INNER JOIN ( | |
SELECT | |
product_additional_sub.pid AS pid, | |
product_additional_sub.url AS url, | |
product_additional_sub.article AS article, | |
product_additional_sub.cid AS cid | |
FROM | |
product_additional AS product_additional_sub | |
WHERE | |
is_active = '1' | |
ORDER BY | |
sorting ASC | |
) AS product_additional ON product_additional.cid = product_color.id | |
GROUP BY | |
product_additional.pid | |
) AS product_additional_val ON product.id = product_additional_val.pid | |
WHERE | |
product.is_active = '1' | |
GROUP BY | |
product.id | |
ORDER BY | |
product.sorting ASC, | |
product.id DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment