Mysql
 sql >> Base de données >  >> RDS >> Mysql

récupérer et imprimer les valeurs après le séparateur virgule d'un seul champ en utilisant la jointure (codeigniter)

utilisez ceci

function getTask($id, $is_master_admin)
{

$this->db->select('task.*, workspace.title as workspacetitle, GROUP_CONCAT( user.title ) AS usertitle,task.assigneduserid,user.id',FALSE);
$this->db->join(WORKSPACE , WORKSPACE . '.id = ' . TASK . '.workspaceid', 'inner');
$this->db->join(USER,("FIND_IN_SET(USER .id , TASK.assigneduserid)"), 'inner');
$this->db->from(TASK);
$this->db->group_by("task.id");
if (!$is_master_admin)
{

$this->db->where ("FIND_IN_SET($id, task.assigneduserid)");
}
$this->db->where(TASK . '.tasktypeid', '1');
$query = $this->db->get();

if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}

}