如何在laravel 5中联合查询?
我的常规查询如下:如何在laravel 5中联合查询?,laravel,laravel-5,union,Laravel,Laravel 5,Union,我的常规查询如下: select "tb_news"."id" as "id", "tb_news"."title" as "title", "tb_news"."content" as "content" from "tb_news" where "tb_news"."id" = 95 union select "tb_news_two"."id" as "id", "tb_news_two"."title" as "title", "tb_news_two"."content" as
select "tb_news"."id" as "id", "tb_news"."title" as "title", "tb_news"."content" as "content"
from "tb_news"
where "tb_news"."id" = 95
union
select "tb_news_two"."id" as "id", "tb_news_two"."title" as "title", "tb_news_two"."content" as "content"
from "tb_news_two"
where "tb_news_two"."id" = 95
$news_two = DB::table('tb_news_two')->select('tb_news_two.id AS id','tb_news_two.title AS title ','tb_news_two.content AS content')
->where('tb_news_two.id',$news_id);
$news = DB::table('tb_news')->select('tb_news.id AS id','tb_news.title AS title ','tb_news.content AS content')
->union($news_two)
->where('tb_news.id',$news_id);
我将常规查询更改为查询laravel
我的laravel查询如下:
select "tb_news"."id" as "id", "tb_news"."title" as "title", "tb_news"."content" as "content"
from "tb_news"
where "tb_news"."id" = 95
union
select "tb_news_two"."id" as "id", "tb_news_two"."title" as "title", "tb_news_two"."content" as "content"
from "tb_news_two"
where "tb_news_two"."id" = 95
$news_two = DB::table('tb_news_two')->select('tb_news_two.id AS id','tb_news_two.title AS title ','tb_news_two.content AS content')
->where('tb_news_two.id',$news_id);
$news = DB::table('tb_news')->select('tb_news.id AS id','tb_news.title AS title ','tb_news.content AS content')
->union($news_two)
->where('tb_news.id',$news_id);
但是,我的laravel查询不起作用
如何将laravel中的联合与一起使用,其中
谢谢您收到了什么错误消息?@user3158900,已解决