php id等于null,php – yii2在查询中选择NULL值(选择NULL作为列,…)

有没有办法在YII2中的查询中选择NULL值或精确字符串?

我正在尝试加入3个查询,我需要相同数量的列查询,例如“选择NULL作为返回,提交,数量,NULL作为iamount …..”

例:

$subQuery2 = Loan::find()->select('person_id')->where(['sheet_id' => $id]);

$query2 = new Query();$query2 = new Query();

$query2->select(['last_name','first_name','fc.tax','NULL as returned','fc.submitted','fc.amount','NULL as iamount','NULL as interest',

'b.month','b.year','b.nb'])

->from('sheet as b')

->join('JOIN', 'fee as fc',

'b.id = fc.sheet_id')

->join('JOIN','person','fc.person_id = person.id')

->where(['b.id' => $id])

->andWhere(['not in', 'person_id', $subQuery2]);

$query = new Query();

$query->

select(['last_name','first_name','fc.tax','fi.returned','fc.submitted','fc.amount','fi.amount as iamount','fi.interest',

'b.month','b.year','b.nb'])

->from('sheet as b')

->join('RIGHT JOIN', 'fee as fc',

'b.id = fc.sheet_id')

->join('JOIN','person','fc.person_id = person.id')

->join('LEFT JOIN','loan as fi',

'b.id = fi.sheet_id and fc.person_id = fi.person_id')

->where(['b.id' => $id])

->union($query2)

->orderBy(['last_name' => SORT_DESC]);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值