gpt4 book ai didi

mysql - LAravel 查询生成器 - 有点不同的 Where 查询

转载 作者:行者123 更新时间:2023-11-29 05:16:05 25 4
gpt4 key购买 nike

我有一个像这样的项目表-

asdf

我想选择公司 ID 为 0 和 2 的所有数据(公司 ID 可能是 1,3,3,4,5,6,...)。

所以,我在 Laravel 查询生成器中所做的是 -

 DB::table( 'project')
->where('project.is_archived', '=', 0)
->where('project.companyID', '=', 0)
->orwhere('project.companyID', '=', 2)
->get;

但它不起作用。

有人可以帮忙吗?

最佳答案

 DB::table('project')
->where('is_archived', 0)
->whereIn('companyID', [0, 2])
->get();

这应该有效:)

关于mysql - LAravel 查询生成器 - 有点不同的 Where 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32635451/

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