title: Yii2: joinWith andFilterWhere with find_in_set
body: <p>I am trying to convert an SQL query like this</p>
  
  <pre><code>select 
  t1.id,t1.form,t1.type,
  group_concat(t2.department) as departments
  from appraisal t1 
  join department t2 on find_in_set(t2.id,t1.dept) 
  group by t1.id
  </code></pre>
  
  <p>into yii2 AppraisalSearch model.</p>
  
  <p>I tried </p>
  
  <pre><code>$query-&gt;joinWith(['departments' ,  'on find_in_set(department.id,appraisal.dept)   ']);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>$query-&gt;andFilterWhere(
                   ['group_concat','appraisal','departments.department'])
  </code></pre>
  
  <p>, but it does not give correct results.</p>
  
  <p>I also have added relation in appraisal model like </p>
  
  <pre><code>public function getDepartments()
      {
          return $this-&gt;hasMany(Department::className(), ['id' =&gt; 'dept']);
      }
  </code></pre>
  
  <p>What is the correct format to make this query work?</p>
  
  <p>The table structure for appraisal table is </p>
  
  <pre><code>--
  -- Table structure for table `appraisal`
  --
  
  CREATE TABLE `appraisal` (
    `id` int(11) NOT NULL,
    `type` varchar(250) DEFAULT NULL,
    `form` varchar(250) DEFAULT NULL,
    `start_time` date DEFAULT NULL,
    `end_time` date DEFAULT NULL,
    `dept` varchar(250) DEFAULT NULL,
    `admin_id` varchar(250) DEFAULT NULL,
    `appr` varchar(1000) DEFAULT NULL,
    `apps` varchar(1000) DEFAULT NULL,
    `desg_appr` varchar(250) DEFAULT NULL,
    `desg_apps` varchar(250) DEFAULT NULL,
    `remark` varchar(250) DEFAULT NULL,
    `sem` varchar(250) DEFAULT NULL,
    `acad_yr` varchar(250) DEFAULT NULL,
    `date` varchar(250) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `appraisal`
  --
  ALTER TABLE `appraisal`
    ADD PRIMARY KEY (`id`);
  </code></pre>
  
  <p>and table structure for department is </p>
  
  <pre><code>--
  -- Table structure for table `department`
  --
  
  CREATE TABLE `department` (
    `id` int(11) NOT NULL,
    `department` varchar(100) DEFAULT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `department`
  --
  ALTER TABLE `department`
    ADD PRIMARY KEY (`id`);
  </code></pre>
  
  <p>In appraisal table, appraisal.dept , the values are stored in comma separated form, like <code>1,2,33,4</code> . Also how to apply <code>andFilterWhere</code> conditions for <code>departments</code> field</p>