我正在使用带有laravel的查询构建器,并且我试图获得等效的
--fork
查询构建器中的?我怎么能得到相同的结果?
答案 0 :(得分:1)
你可以在whereRaw()
这样做
DB::table('emp')->whereRaw("name+' '+firstname LIKE '%test%'")->select('name', 'firstname')->get();
希望它为你工作!
答案 1 :(得分:1)
$result = DB::table('emp')->select('name', 'firstname')->where(DB::raw("CONCAT('name', ' ', 'firstname')"), 'LIKE', '%'. 'test' .'%')->get();
答案 2 :(得分:0)
尝试将CONCAT
用于多列
DB::table('emp')->Where(DB::raw("CONCAT(`name`, ' ', `firstname`)"), 'LIKE', "%test%")->select('name', 'firstname')->get();
希望这会有所帮助。