gpt4 book ai didi

php - 当我连接两个表时,不返回空值。返回以前的数据

转载 作者:行者123 更新时间:2023-11-28 23:58:45 25 4
gpt4 key购买 nike

在 yii2 中,我编写了连接两个表的左连接查询。

如果基表只有一条记录,而连接表有两条记录..

intProject_Id 是两个表的公共(public)字段

我需要如果一条记录有一个值是 null 意味着它返回 Null..

现在这里会显示以前的数据。

我的 Controller 代码:

$model2 = (new \yii\db\Query())
->select(['tbl_sprint.*','tbl_iteration.*'])
->from('tbl_sprint')
->leftJoin('tbl_iteration', 'tbl_iteration.intProject_Id = tbl_sprint.intProject_Id')
->where('tbl_iteration.intProject_Id = :intProject_Id', [':intProject_Id' => $projectid])
->all();

我的加入表:

This is my joining tableMyBase 表:

This is my base table

我想要这样的输出: This is my out table.. iwant the text null or blank space in the sprint name column of the clearanz2 iteration

请帮我解决这个问题

谢谢。

最佳答案

请尝试以下查询。

$model2 = (new \yii\db\Query())
->select(['tbl_sprint.*','tbl_iteration.*'])
->from('tbl_sprint')
->innerJoin('tbl_iteration', 'tbl_iteration.intProject_Id = tbl_sprint.intProject_Id')
->where('tbl_iteration.intProject_Id = :intProject_Id', [':intProject_Id' => $projectid])
->all();

关于php - 当我连接两个表时,不返回空值。返回以前的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30708377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com