gpt4 book ai didi

php - SQLSTATE[23000] : Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous

转载 作者:行者123 更新时间:2023-12-02 03:58:02 25 4
gpt4 key购买 nike

我的简单查询显示此错误

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();

最佳答案

尝试改变这一点:

->where('status', 1)

对此:

->where('news.status', 1)

您可能在另一个连接表中有另一个名为 status 的字段,因此您需要指定要按 status 进行过滤的表。

关于php - SQLSTATE[23000] : Integrity constraint violation: 1052 Column 'status' in where clause is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49918907/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com