0
Salve Galera , I’m breaking my balls to assemble this query in the IC model
"SELECT *, geral_cnpj as cnpj, geral_mesref as mesref, (SELECT CEILING(( (SELECT `geral_valor_total` as valormes from tbl_geral where `geral_cnpj`=cnpj and `geral_mesref`=mesref) - (SELECT `geral_valor_total`from tbl_geral as valormesanterior where `geral_cnpj`=cnpj and `geral_mesref`=mesref-1) ) / (SELECT `geral_valor_total`as valormes from tbl_geral where `geral_cnpj`=cnpj and `geral_mesref`=mesref)*100 ) ) as valor_percentual FROM tbl_geral";
To query is correct as I have already checked in Mysql and brings the results. I tried to use it this way (which I believe is not correct) and gives me the error
Error Number: HY000/1096
No tables used
SELECT *
follows the method below the model
public function listar_gerais_percentual(){
$q="SELECT *, geral_cnpj as cnpj, geral_mesref as mesref, (SELECT CEILING(( (SELECT `geral_valor_total` as valormes from tbl_geral where `geral_cnpj`=cnpj and `geral_mesref`=mesref) - (SELECT `geral_valor_total`from tbl_geral as valormesanterior where `geral_cnpj`=cnpj and `geral_mesref`=mesref-1) ) / (SELECT `geral_valor_total`as valormes from tbl_geral where `geral_cnpj`=cnpj and `geral_mesref`=mesref)*100 ) ) as valor_percentual FROM tbl_geral";
$result = $this->db->query($q);
return $result;
}
MYSQL 1096 ERROR - NO TABLES USED - CODEIGNITER
– Patrick Perdigão