laravel查询数据库 两个字段相等查询方法

版权声明:阿西莫多 https://blog.csdn.net/yang_yun_hao/article/details/83375021

1.在laravel查询中,我们需要查找两个字段相等的值,这种方法不行

$data = DB::connection('mysql_branch')->table('branches') 
->where('is_usable',1) 
->whereRaw('money','amount')->get();

2.这种也不行

$first_agent = DB::connection('mysql_branch')->table('branches') 
->where('is_usable',1) 
->whereRaw('money','=','amount')->get();

3.需要这样查询

$first_agent = DB::connection('mysql_branch')->table('branches') 
->where('is_usable',1) 
->whereRaw('money=amount')->get();

猜你喜欢

转载自blog.csdn.net/yang_yun_hao/article/details/83375021