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

¿how do I remove the double quotes of a subquery in postgresql?

i have the example next:

Error Number:

ERROR: syntax error at or near "AS" LINE 7: ...d"."udi_id" DESC, "m"."mat_anio_academico"" DESC)" AS "mudi" ^

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 FROM (SELECT DISTINCT ON (mud.udi_id) mud.mud_id FROM "matricula_unidad_didactica" AS "mud" JOIN "matricula" AS "m" ON "mud"."mat_id"="m"."mat_id" 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)" AS "mudi" JOIN "matricula_unidad_didactica" AS "mu" ON "mudi"."mud_id"="mu"."mud_id" JOIN "unidad_didactica" AS "u" ON "mu"."udi_id"="u"."udi_id" JOIN "matricula" AS "m" ON "mu"."mat_id"="m"."mat_id" JOIN "alumno" AS "a" ON "m"."alu_id"="a"."alu_id" WHERE "a"."alu_id" = 415 ORDER BY "u"."sem_codigo" ASC, "u"."udi_letra_nomina" ASC, "m"."mat_anio_academico" ASC

this code has the model:

$this->db->select('DISTINCT ON (mud.udi_id) mud.mud_id',FALSE);
$this->db->from('matricula_unidad_didactica AS mud');
$this->db->join('matricula AS m', 'mud.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('mud.udi_id, m.mat_anio_academico', 'DESC');

$subquery =  $this->db->get_compiled_select();

$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->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,u.udi_letra_nomina,m.mat_anio_academico','ASC');
$query = $this->db->get("(".$subquery.") AS mudi");
return $query;


¿Could they help me? thanks!!
Reply


Messages In This Thread
remove the double quotes of a subquery - by andresweb - 12-20-2015, 09:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB