[英]SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous
My simple query showing this error 我的简单查询显示此错误
DB::table('news')->join('categories', 'news.category_id', '=', 'categories.id')
->join('users', 'news.created_by', '=', 'users.id')
->select('news.*', 'categories.name as category_name','users.name as user_name','categories.bn_name','users.photo','news.photo as n_photo')
->where('status', 1)
->orderBy('news.id', 'desc')
->take(5)
->get();
try to change this: 试着改变这个:
->where('status', 1)
to this: 对此:
->where('news.status', 1)
Probably you have in another join table another field called status
so you need to specify the table where you want to filter by status
. 可能在另一个连接表中有另一个名为status
字段,因此您需要指定要按status
过滤的表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.