当我添加最后一行“和@summ > 0(任何条件)”时,它返回空结果。我做错了什么?如何正确地将@summ传递给 where 子句?
select
nore.nis as nore_curent,
field_funds.value,
(select @summ :=
sum(field_amount.value - field_amount_tip.value)
from
nore
inner join field_project on nore.nis = field_project.id
inner join field_funds on field_funds.id = field_project.target_id
inner join field_amount on nore.nid = field_data_field_amount.id
inner join field_amount_tip on nore.nis = field_amount_tip.id
where
nore.`s` = 1
and
nore.`t` = 'p'
and
field_project.target_id = nore_curent) as amount
from
nore
inner join field_funds on nore.nis = field_funds.id
where
nore.`s` = 1
and
nore.`t` = 'pp'
and @summ > 0