Laravel, uses union to connect multiple queries, and an error will be reported when a query is empty. How to solve this problem?

there are three tables of A _

$a=DB::table("A")->where("some condition");
$b=DB::table("B")->where("some condition");
$c=DB::table("C")->where("some condition")->union($a)->union($b);

if the result set of $an or $b is empty, an error will be reported.
the solution now is to judge $a-> get () and $b-> get (), respectively, and union them if they are not empty, but there are actually a large number of tables, and each judgment is too inelegant.

so is there any elegant solution?

Mar.02,2021

http://www.it1352.com/671764.

I hope it will be helpful to you

yard farmhouse

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e53731-4523b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e53731-4523b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?