select name, case
WHEN iso2 = 'DE' THEN 'Germany'
WHEN iso2 = 'CH' THEN 'Switzerland'
ELSE 'India' End
from cities
When I convert
DB::table('cities')->select('id as city_id', 'name as lang_name', 'ascii_name as city_name', 'iso2', DB::raw('(CASE WHEN iso2 = "DE" THEN "Germany" WHEN iso2 = "CH" THEN "Switzerland" ELSE "India" END) AS codeCity'))->get();
````
It shows error
column "DE" does not exist LINE 2
@babuyadhu can you check the query from query builder
dd(
DB::table('cities')->select('id as city_id', 'name as lang_name', 'ascii_name as city_name', 'iso2', DB::raw('(CASE WHEN iso2 = "DE" THEN "Germany" WHEN iso2 = "CH" THEN "Switzerland" ELSE "India" END) AS codeCity'))->__toSql()
);
$c_list = DB::table('cities')
->select('id as city_id', 'name as lang_name', 'ascii_name as city_name', 'iso2', DB::raw("case
WHEN iso2 = 'DE' THEN 'Germany'
WHEN iso2 = 'CH' THEN 'Switzerland'
ELSE 'India' End AS codeCity"))
->get();
print_r($c_list);