Welcome Guest, Not a member yet? Register   Sign In
remove the double quotes of a subquery
#5

I returned to the simple example

$subquery = 'SELECT DISTINCT ON (mud.udi_id) mud.mud_id FROM matricula_unidad_didactica AS mud INNER JOIN matricula AS m ON mud.mat_id=m.mat_id INNER JOIN alumno AS a ON m.alu_id=a.alu_id WHERE a.alu_id = 415 ORDER BY mud.udi_id DESC,"m"."mat_anio_academico" DESC';

$this->db->select('m.mat_anio_academico,mu.udi_id,u.udi_nombre,u.sem_codigo,u.udi_letra_nomina,mu.mud_nota_final,mu.mud_nota_recuperacion,m.mma_id',FALSE);

$this->db->from("($subquery) AS mudi");
$this->db->join('matricula_unidad_didactica AS mu','mudi.mud_id=mu.mud_id');
$this->db->join('unidad_didactica AS u','mu.udi_id=u.udi_id');
$this->db->join('matricula AS m','mu.mat_id=m.mat_id');
$this->db->join('alumno AS a','m.alu_id=a.alu_id');
$this->db->where('a.alu_id',415);
$this->db->order_by('u.sem_codigo','ASC');
$this->db->order_by('u.udi_letra_nomina','ASC');
$this->db->order_by('m.mat_anio_academico ASC');
$query = $this->db->get();
return $query;

in the variable $subquery if I remove the final order by

,"m". "mat_anio_academico" DESC

It works !!

but I need both.

Is there any extra help?
Reply


Messages In This Thread
RE: remove the double quotes of a subquery - by andresweb - 12-22-2015, 09:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB