Query builder subquery added multiple quotes if select more than 1 column |
@nata,
I don't understand your question. Are you receiving errors? Are you asking if what you have above is correct? Here are some possible solutions: - https://stackoverflow.com/questions/4610...n-subquery - Query Binding ( https://www.codeigniter.com/user_guide/d...y-bindings ). This will allow you to do the following... $sql = "SELECT pendaftaran_id, pendaftaran_tanggal FROM (SELECT trx_no, pendaftaran_id FROM t_transaksi GROUP BY trx_no, pendaftaran_id) as t_trx JOIN t_pendaftaran ON t_pendaftaran.pendaftaran_id = t_trx.pendaftaran_id"; $this->db->query($sql); - Or you could create a database view (with the generated query in the database) and then call the view in CI. |
Welcome Guest, Not a member yet? Register Sign In |