【问题标题】:Laravel Eloquent Error (SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer)Laravel Eloquent 错误(SQLSTATE [22P02]:无效的文本表示:7 错误:整数的输入语法无效)
【发布时间】:2018-08-16 04:59:23
【问题描述】:

我尝试通过使用以下查询加入 3 个表来检索数据,但它返回了上述错误(在标题中)。我无法发现问题所在。提前谢谢你。

$data = DB::connection('pgsql_backoffice')
            ->table('tusers')
            ->join('tservices','tusers.user_id','=','tservices.user_id')
            ->join('tnotify_send_info','tnotify_send_info.user_id','=','tnotify_send_info.user_id')
            ->select('tusers.user_id','tservices.account_no','tusers.cust_type','tusers.first_name','tusers.last_name','tusers.company_name','tservices.created_t','tservices.start_t','tnotify_send_info.notify_actual_date')
            ->where('tservices.plan_id','tnotify_send_info.package_id')
            ->get();

错误说'tnotify_send_info.package_id'有问题

【问题讨论】:

  • 你能告诉我们完整的错误信息吗?

标签: laravel eloquent


【解决方案1】:

使用whereColumn() 比较列:

->whereColumn('tservices.plan_id', 'tnotify_send_info.package_id')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-09
    • 2020-10-01
    • 1970-01-01
    • 2012-12-21
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多