2016-09-29 29 views
0

相当基本;组函数无效。我知道我需要使用HAVING,但不知道如何重写它。这里基本的东西:无效的组功能

+0

可能重复的[是否有任何\ _VALUE能力的MySQL 5.6?](http://stackoverflow.com/questions/37089347/is-there-any-value-capability-for-mysql-5-6 ) – e4c5

回答

0

您无法通过使用像计数聚合函数没有一个组,然后分配到该值,结果
在这种情况下,你应该使用合适的子查询为获得价值在d.products_count

分配
update deals d 
join deal_products dp on dp.deal_id = d.id 
set d.products_count = (select count(distinct product_id) 
         from your_table where Your_condition) 
where dp.active_flag=1 and dp.enabled_flag=1 and d.status != 'deleted';