加入错误的问题:1054

我尝试使用 a join, 并以数组作为条件:

$task = Task::join('oc_groups', function($join) use ($filter) {
    foreach($filter['groups']['data'] as $key => $value) {
        $join->on('oc_groups.id', $value); 
    }
}); 

但我收到错误消息:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '1' in 'on clause' (SQL: select oc_tasks.title as task_title from oc_tasks inner join oc_groups on oc_groups.id = 1 where oc_tasks.task_date between 2017-07-01和 2017-07-31)

1是的内容$value我做错了什么?- 该表oc_groups有一个名为 的字段id

比布达塔萨胡

由于这两个表之间没有任何关系,因此请尝试加入。像这样

select `oc_tasks`.`title` as `task_title` from `oc_tasks` ,`oc_groups`  
where `oc_tasks`.`task_date` between 2017-07-01 and 2017-07-31 and `oc_groups`.`id` = `1`

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章