Invalid column name '' to concatenate columns using Laravel 4 Eloquent?

So, I want to prepare a list for placement in combobox with laravel, and I wanted to use concatenate to join the value of 3 columns, and I can achieve this with

public function deviList() {
        return Device::select(DB::raw('CONCAT(DESC, OS, OS_V) AS FullDesc'), 'DEVI_ID')                        
                        ->where('STATUS', 2)
                        ->orderBy('DESC')
                        ->lists('FullDesc', 'DEVI_ID');
    }

However, it would be better to have a space or a slash separating the values ​​of the columns, so I did it the same way as some people recommended in some other places:

public function deviList() {
        return Device::select(DB::raw('CONCAT(DESC," ",OS," ",OS_V) AS FullDesc'), 'DEVI_ID')                        
                        ->where('STATUS', 2)
                        ->orderBy('DESC')
                        ->lists('FullDesc', 'DEVI_ID');
    }

However, I get the SQLSTATE [42S22] error message : [Microsoft] [ODBC 11 driver for SQL Server] [SQL Server] Invalid column name '' (So ​​I suppose, unlike the examples elsewhere, these partitions are read as if they were columns?) So, how can I concatenate with some sort of partition?

+4
2

SQL Server QUOTED_IDENTIFIER, , . " " , , (), , .

SQL-:

public function deviList() {
    return Device::select(DB::raw("CONCAT(DESC,' ',OS,' ',OS_V) AS FullDesc"), 'DEVI_ID')                        
        ->where('STATUS', 2)
        ->orderBy('DESC')
        ->lists('FullDesc', 'DEVI_ID');
}

QUOTED_IDENTIFIER docs .

+2

, SQL Server, , , CONCAT. - :

SELECT (COALESCE(col1, '') + '' + COALESCE(col2, '')) AS col3 FROM ...

, , :

public function deviList() {
  return Device::select(DB::raw('(COALESCE(DESC, "") + " " + COALESCE(OS, "") + " " (COALESCE(OS_V, "")) AS FullDesc'), 'DEVI_ID')                        
    ->where('STATUS', 2)
    ->orderBy('DESC')
    ->lists('FullDesc', 'DEVI_ID');
}

, , , COALESCE() , null, , FullDesc .

, .

0

All Articles