mysql - Unknown Column In Where Clause With Join -


i want join 3 table 1 column sum has compare column

here query

select      *, `e`.`id` `event_ac_id`,      sum(case when trans.gift_transaction_status = 1                 trans.event_gift_amount                  else 0 end) amount       `tbl_event_category` `cat`  left join      `tbl_event` `e` on e.event_category = cat.id  left join      `tbl_organisation` `org` on e.organisation_id = org.id  left join      `tbl_event_gift_transaction` `trans` on e.id = trans.event_id       cat.type ='campaign' , is_approved=1     , e.funding_goal_amount <= amount  group      `event_ac_id`  limit 8 

exception (database exception) 'yii\db\exception' message 'sqlstate[42s22]: column not found: 1054 unknown column 'amount' in 'where clause'

the filter on aggregate values base on having

could need

select *, `e`.`id` `event_ac_id`,     sum(case when trans.gift_transaction_status = 1 trans.event_gift_amount      else 0 end) amount  `tbl_event_category` `cat` left join `tbl_event` `e`         on e.event_category=cat.id  left join `tbl_organisation` `org` on e.organisation_id=org.id  left join `tbl_event_gift_transaction` `trans` on e.id=trans.event_id   cat.type ='campaign'    , is_approved=1   having  e.funding_goal_amount <= amount   group `event_ac_id` limit 8 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -