如何在Laravel中执行MYSQL查询? [英] How to execute MYSQL query in laravel?
本文介绍了如何在Laravel中执行MYSQL查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个MYSQL查询,我想在laravel中执行此查询.
I have one MYSQL query with me I want to execute this query in laravel.
select d1.update_id from ( select update_id, count(update_id)
as ct from updates_tags where tag_id in
(67,33,86,55) group by update_id) as d1 where d1.ct=4
请指导我如何轻松进行操作.
Please guide me how do i Do it easily.
我有一个参考....不起作用
I have one reference with me.... It is not working
$updateArray = DB::table('updates_tags')
->select('update_id', DB::raw('count(*) as update_id'))
->whereIn('tag_id',$jsontags)
->groupBy('update_id')
->having('update_id','=',count($jsontags))
->lists('update_id');
推荐答案
您可以只执行RAW查询. 像这样:
You can just do a RAW query. like this:
$sqlQuery = "SELECT d1.update_id FROM...";
$result = DB::select(DB::raw($sqlQuery));
$ result将是一个数组
the $result will be an array
这篇关于如何在Laravel中执行MYSQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文