у меня две таблицы и два соединения
(mysql) работает для одной таблицы - dbname_web
(mysqlShop) работает для второй таблицы - dbname_shop
все три запроса работают нормально, но когда я использую union
первое соединение потеряно и показывает только второе соединение от mysqlShop
ошибка laravel: dbname_shop. Новостей не существует
должно быть dbname_web.News
$News = DB::connection('mysql')->table('News')->selectRaw("title_ge as name, CONCAT('$news_url/', id) as url")
->where("title_ge","LIKE","%{$request->input('query')}%")
->orWhere("full_text_ge","LIKE","%{$request->input('query')}%");
$Album = DB::connection('mysql')->table('Album')->selectRaw("title_ge as name, CONCAT('$album_url/', id) as url")
->where("title_ge","LIKE","%{$request->input('query')}%")
->orWhere("full_text_ge","LIKE","%{$request->input('query')}%");
$Products = DB::connection('mysqlShop')->table('Products')->selectRaw("title_ge as name, CONCAT('$product_url/', id) as url")
->where("title_ge","LIKE","%{$request->input('query')}%")
->orWhere("soft_id","LIKE","%{$request->input('query')}%")
->orWhere("full_text_ge","LIKE","%{$request->input('query')}%");
$result = $Products->union($News)->union($Album)->get();
return response()->json($result);
Вывод SQL
(select title_ge as name, CONCAT('http:\/\/nova.ge\/product\/item\/', id) as url from `Products` where `title_ge` LIKE ? or `soft_id` LIKE ? or `full_text_ge` LIKE ?) union (select title_ge as name, CONCAT('http:\/\/nova.ge\/news\/', id) as url from `News` where `title_ge` LIKE ? or `full_text_ge` LIKE ?) union (select title_ge as name, CONCAT('http:\/\/nova.ge\/album\/', id) as url from `Album` where `title_ge` LIKE ? or `full_text_ge` LIKE ?)
и ошибка
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'novage_shop.News' doesn't exist (SQL: (select title_ge as name, CONCAT('http://nova.ge/product/item/', id) as url from `Products` where `title_ge` LIKE %test search% or `soft_id` LIKE %test search% or `full_text_ge` LIKE %test search%) union (select title_ge as name, CONCAT('http://nova.ge/news/', id) as url from `News` where `title_ge` LIKE %test search% or `full_text_ge` LIKE %test search%) union (select title_ge as name, CONCAT('http://nova.ge/album/', id) as url from `Album` where `title_ge` LIKE %test search% or `full_text_ge` LIKE %test search%))