查询执行
如何在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
可以链where
条件与口才,每一个链评价像and
。
$update = Tag::whereIn('t_id',$tags)->whereIn('u_id',$tags)->where(/*more and conditions you could need*/)->lists('u_id')
编辑:如果你需要的那些与U_ID一致认为这样的:
$update = DB::table('tags')
->select('t_id', 'u_id', DB::raw('count(*) as total'))
->whereIn('t_id',$tags)
->where('total','=',count($tags))
->groupBy('u_id')
->lists('u_id');
我想根据t_id将其用于过滤器。如果多个t_id包含相同的u_id,那么它应该是打印。一次可能有多个t_id 2或4,我该如何检查? – Ankit
vivoconunxino:我想u_id列表不是t_id。我是laravel的乞丐。如果t_id(11,21)相同u_id那么我需要那个u_id。 – Ankit
请检查并尝试编辑 – vivoconunxino
您可以使用Laravel
$results = DB::select(SELECT * FROM table WHERE id IN (1,2,3,4) AND);
原始查询这些类型的查询可以使用whereRaw() –
没有得到结果。我想使用这个基于t_id的过滤器。如果多个t_id包含相同的u_id,那么它应该是打印。 – Ankit