如何将工作查询转换成雄辩的流明配置

kzmpq1sx  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(290)

亲爱的,
我使用这个工作查询从两个pgsql表中检索令牌和appid信息。我正在尝试使用lumen框架实现一个api。如何将此查询转换为雄辩的语句?因此可以配置控制器部分。我试过这个http://cryptic-peak-77605.herokuapp.com/ 但没有成功

SELECT token,appid FROM db.public.tokens WHERE id = (SELECT id FROM db.public.data WHERE (name,value) IN (('userName', '100'), ('domain', '1591.xpto.xyz' )) group by id having count(distinct VALUE) = 2);
anhgbhbe

anhgbhbe1#

你可以这样做。

$records = YourModel::where('id', DB::select("SELECT id FROM data WHERE (name,value) IN (('userName', '100'), ('domain', '1591.xpto.xyz' )) group by id having count(distinct VALUE) = 2"))->select(['token', 'appid'])->get();

但是从上面的查询来看,如果我们继续使用一个完整的原始查询(如

$records = DB::select("SELECT token,appid FROM tokens WHERE id = (SELECT id FROM data WHERE (name,value) IN (('userName', '100'), ('domain', '1591.xpto.xyz' )) group by id having count(distinct VALUE) = 2);");

相关问题