vegetable, fruit, millet,cereal are catagories with e_id=0.
The following is the code using ActiveRecord.
'condition'=>"t.name LIKE :sub AND t.e_id IN(SELECT edible.id FROM edible WHERE e_id=0 AND edible.name LIKE :main)",
foreach($items as $item)
echo $item->name."</br>";//brings apple,orange,banana,grape from FRUITS and wheat and maze from CEREAL
We are using LIKE, there there are many chances to get more than one record.