如果我有两个字段(比如说field1和field2)
如何在Eloquent中创建此查询?
SELECT * FROM `table` WHERE `field1` < `field2`;
$query->where('field1','<','field2')
不起作用。反引号也不起作用......
答案 0 :(得分:3)
$query->whereRaw('field1 < field2');
答案 1 :(得分:0)
$users = DB::table('users')
->where('field1', '<', 'field2')
->get();
在Eloquent中
$users = User::where('field1', '<', 'field2')
->get();