I'm trying to select multiple database columns and to merge them to an AS value statement like SELECT sum1 as vsd FROM tablename WHERE year = 2017
I have multiple columns I need to output as one value. So I imagine the above code looking something like this:
SELECT (sum1, sum2) as vsd FROM tablename WHERE year = 2017
My current live-code query looks like this:
$query = DB::table('exports')->select('id', 'year', 'week', 'month', 'staff_a, staff_b as vsd')->having('year','=',$year)->where('week', '<=', $weeknr)->orderBy('id', 'desc')->take(14)->get()->reverse();
The result is:
Column not found: 1054 Unknown column 'staff_a, staff_b' in 'field list'
I tried to combine them (columns) to an array (array('staff_a', 'staff_b')), had some weird foreach-loops and whatnot trying to make it work another way but all that threw yet another error message.
Is there any way to "merge" multiple selects to one?
(sum1, sum2) as vsdthis is not merging even in mysql. How do you want to merge them ? by adding both columns sum1 + sum2 as vsd?