CodeIgniterでの結合でDistinctを使用するにはどうすればよいですか?顧客の名前と登録されたカテゴリを取得しようとしていますが、カテゴリを使用していますが、別のものを使用しましたが、あいまいなフィールドエラーが発生しました。どのようにこの問題を解決できますか。 マイビューcodeigniterの結合で明白です
<table class="table table-hover example1">
<thead>
<tr>
<th>SNo.</th>
<th>Business Name</th>
<th>Category Name</th>
<th>Edit</th>
</tr>
</thead>
<tbody>
<?php $i=0;
foreach($value as $row){ ?>
<tr>
<td><?php echo ++$i;?></td>
<td><?php echo $row->Bussiness_Name;?></td>
<td><?php echo $row->Category_Name;?></td>
<td onClick="RestoreVendor(<?php echo $row->Business_Id; ?>,<?php echo $row->Trash;?>,'<?php echo $row->Bussiness_Name;?>')" class="btn btn-primary">Remove</td>
</tr>
<?php }?>
</tbody>
</table>
マイコントローラー:
public function removecategory()
{
$this->load->model('VendorModel');
$data = $this->VendorModel->remove_category();
$this->load->view('admin/remove_cat', array('value'=>$data));
}
マイモデル
public function remove_category()
{
$this->db->select('*');
$this->db->distinct('Category_Id');
$this->db->from('business_mapping');
$this->db->join('business_profile_details', 'business_profile_details.Business_Id = business_mapping.Business_Id');
$this->db->join('category_master', 'category_master.Category_Id = business_mapping.Category_Id');
$query = $this->db->get();
return $query->result();
}
結果画像 enter image description here
これを使って、カテゴリごとに1つのデータが得られます。これは私のために働いていません。 –
私はここにスクリーンショットを追加しました。リンクはhttps://i.stack.imgur.com/fEk8Y.png –
です。@StutiRauthan:この障害からあなたを助けてくれてうれしいです。 –