I have a question that I am asking, the fact is that I am very bad at doing it.
My table: payments_credit With its columns: credit_pay_id, contract_id, acquisition_date, credit_credit.
I try to get the LAST "id_pagos_credito" from my "contrato_id" (so far so good with my current query) but I need to show me the record of any of the other columns, for example: the value of "Cost_credit". What I wear:
SELECT MAX(id_pagos_credito) FROM pagos_credito WHERE contrato_id=1
id_pagos_credito | contrato_id | date_acquisition | cost_credit
1 | 1 | 2018-04-11 | 100
2 | 2 | 2018-04-09 | 50
3 | 1 | 2018-04-08 | 20
4 | 2 | 2018-04-10 | 200
I would like you to show me when I run the query (cost_credito de contrato_id) of 2: 200 (date_acquisition of contract_id) of 1: 2018-04-08
Well, it's basically selecting the last value (not the greatest) of X table based on your ID. I hope to make myself understood, this is the basis to be able to pass it to codeigniter by passing parameters. Thanks