简体   繁体   English

SQLSTATE [23000]:完整性约束违规:1052 where子句中的列'status'不明确

[英]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.

相关问题 SQLSTATE [23000]:违反完整性约束:1052 where 子句中的列“值”不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'value' in where clause is ambiguous Laravel Eloquent SQLSTATE[23000]:违反完整性约束:1052 列...在 where 子句中不明确 - Laravel Eloquent SQLSTATE[23000]: Integrity constraint violation: 1052 Column ... in where clause is ambiguous Laravel 6 错误:SQLSTATE[23000]:违反完整性约束:1052 where 子句中的列“id_perusahaan”不明确 - Laravel 6 Error : SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_perusahaan' in where clause is ambiguous SQLSTATE [23000]:完整性约束违规:1052 where子句中的列'NRP'不明确 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'NRP' in where clause is ambiguous SQLSTATE [23000]:完整性约束违规:1052 order order中的'created_at'列不明确Laravel 5.5 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous Laravel 5.5 Yii2 GridView:SQLSTATE[23000]:违反完整性约束:1052 order 子句中的列“id”不明确 - Yii2 GridView: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in order clause is ambiguous SQLSTATE [23000]:完整性约束违规:1052 列“created_at”在 order 子句中不明确 Laravel 8 - SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguous Laravel 8 完整性约束违规:1052 where子句中的列'id'不明确 - Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous Laravel 完整性约束违规:1052 列 'id' in where 子句不明确 - Laravel Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous PDOException:SQLSTATE [23000]:违反完整性约束:1052 IN / ALL / ANY子查询中的列“ category_id”不明确 - PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'category_id' in IN/ALL/ANY subquery is ambiguous
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM