你好,我有这个查询,我使用orWhere
和Join
但不工作。这是我的查询:
$hasBorrowedCars = CarBorrow::query()
->where('borrowed_from_user_id', $userId)
->orWhere(function ($query) use ($userId) {
$query->join('car_owners', 'user_id', '=', 'car_owners.user_id')
->where('user_id', $userId);
})
->exists();
这是我得到的错误:
Column not found: 1054 Unknown column 'user_id' in 'where clause' (SQL: select exists(select * from `car_borrows` where `borrowed_from_user_id` = 2 or (`user_id` = 2)) as `exists`)
1条答案
按热度按时间jvlzgdj91#
join子句中缺少表名。假设表名为
car_borrows