0

I tried to use a join, with an array given as a condition:

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

But I get the error message :

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 and 2017-07-31)

The 1 is the content of the $value. What I am doing wrong? - The table oc_groups has a field named id.

Zayn Ali
  • 4,765
  • 1
  • 30
  • 40
yfain
  • 509
  • 7
  • 23

1 Answers1

1

As you don't have any relation between these two tables so Try with out join. like this

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`
Bibhudatta Sahoo
  • 4,808
  • 2
  • 27
  • 51
  • Thanks. Helped me a lot. But the best solution is to have relations between those tables I think. – yfain Aug 02 '17 at 10:45