我想在lumen中使用case,但它返回消息“oops!发生错误。服务器返回500内部服务器错误。“
//Working
$result = DB::table('Users')
->select(DB::raw('count(*) as user_count'))
->where('user_id', 'A1')
->get();
// Working
$result = DB::select('SELECT CASE WHEN user_status="new" THEN "New" ELSE "Expired" END AS new_status FROM Users WHERE user_id="A1"');
//Failed
$result = DB::table('Users')
->select(DB::raw('CASE WHEN user_status="new" THEN "New" ELSE "Expired" END AS new_status'))
->where('user_id', 'A1')
->get();
为什么失败了?
流明7.0
谢谢您。
1条答案
按热度按时间jjhzyzn01#
请试试这个: