[英]How to check two condition in single query in mysql?
例
------------------------------------------
Amount | Type
------------------------------------------
1000 | credit
------------------------------------------
4500 | credit
------------------------------------------
1250 | debit
------------------------------------------
500 | credit
------------------------------------------
select IFNULL(SUM(amount),0) as Credit_Amount,IFNULL(SUM(amount),0) as Debit_Amount,
type,party from receipt where party='$list[id]' and type='credit' or
type='debit'
产量
Credit_Amount = 6000
Debit_Amount = 1250
在这里,如果类型是credit,则值应与credit
变量相加;如果type是debit,则值应与debit
相加。 请帮助我解决这个问题。
这是信用查询,您只能根据要求附加。
Select IF(type='Credit', SUM(amount), null) as Credit from receipt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.