【发布时间】:2019-01-19 07:23:04
【问题描述】:
我的查询遇到了一个问题,即 group by 没有与工会合作。 以下是查询:
(select products.*, sum(100000) as count1, product_sku.price AS sku_price, product_sku.label AS sku_label from `products` left join `product_sku` on `products`.`id` = product_sku.product_id AND product_sku.is_primary = "Yes" AND products.is_variation = "Yes" where `product_name` = "testproduct1" and `status` = "Active" and exists (select * from `campaign` where `products`.`exclusive_for` = `campaign`.`id` and `status` = "Published" and `active_inactive` = "Active" or `products`.`exclusive_for` is null) group by `products`.`id` having id != 0)
union
(select products.*, ROUND ( (LENGTH(products.product_name)- LENGTH( REPLACE ( products.product_name, "testproduct1", "") ) ) / LENGTH("testproduct1") ) AS count1, product_sku.price AS sku_price, product_sku.label AS sku_label from `products` left join `product_sku` on `products`.`id` = product_sku.product_id AND product_sku.is_primary = "Yes" AND products.is_variation = "Yes" where (`products`.`product_name` LIKE "%testproduct1%" or `products`.`description` LIKE "%testproduct1%") and `status` = "Active" and exists (select * from `campaign` where `products`.`exclusive_for` = `campaign`.`id` and `status` = "Published" and `active_inactive` = "Active" or `products`.`exclusive_for` is null) having id != 0 )
group by `p_id`
请帮帮我。
【问题讨论】:
-
不工作是什么意思?
-
它给了我语法错误。
-
然后将错误信息添加到您的问题中
-
请添加您的错误。以便我们轻松跟踪您的实际问题。